2339 Commits

Author SHA1 Message Date
John Detter 4b41cf3d71 Updated change license date
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
v1.3.2
2025-08-27 10:38:47 -05:00
John Detter 7636f45209 Linted 2025-08-27 06:54:45 -05:00
John Detter 72e8790e0a Make CI happy 2025-08-27 06:49:39 -05:00
John Detter 6a22e39727 Not sure why the license didn't get updated 2025-08-27 06:47:51 -05:00
John Detter d6557ad2ac Version upgrade to 1.3.2 2025-08-27 06:47:47 -05:00
Phoebe Goldman 70b061fad3 Change comment: there's no index here even after bootstrap 2025-08-27 06:22:22 -05:00
Phoebe Goldman ef7ce4faac Sort columns in st_column_changed before automigrating.
During bootstrapping, indexes don't exist,
so `iter_by_col_eq` returns rows in physical storage order.
In simple cases (without unrelated deletes) this will be the same as insertion order,
and therefore also the same as sorted order,
but in cases with multiple column-changing automigrations
the physical storage order of the rows diverges from the correct sorted order.
Because this isn't a hot path, we can just call `.sort()` and not worry about it.
2025-08-27 06:22:16 -05:00
Mazdak Farrokhzad 2d1f9bf8a0 alter_table_row_type: write changes to st_column 2025-08-26 11:21:13 -05:00
Mazdak Farrokhzad 8c5fbe416f st_column_changed: use newly inserted row for column 2025-08-26 11:20:26 -05:00
Mazdak Farrokhzad d670f5cee6 replay: on insert/delete on st_column, refresh target table 2025-08-26 11:20:21 -05:00
Mazdak Farrokhzad 9bccff3ec8 Revert "Disable column type changes in an automigration (#3178)"
This reverts commit be1bd22518.
2025-08-26 11:20:13 -05:00
Shubham Mishra cc4a165627 fix #3174 (#3179)
# Description of Changes
fixes #3174 .
During initialization, entries were added to the `DelayQueue` but not to
`key_map`.

### Detailed Explanation:

1. `DelayQueue` is **not set-semantic**, so we track uniqueness with a
`key_map: FxHashMap` but that wasn't updated during initiliaziation.

2. `Scheduler::schedule` is **not transactional**: it enqueues reducers
even if the DB transaction later fails (abort, duplicate row, etc.). On
yield, `SchedulerActor` checks the DB before execution.


**Combined Effect**: A transaction that does not actually change a
scheduled entry but still calls `Scheduler::schedule` after a module
update will cause a duplicate entry in the `DelayQueue`, since `key_map`
does not yet contain that entry.

**Why It Didn’t Show Earlier**:
When a repeating reducer executes, we re-schedule it by updating both
`DelayQueue` and `key_map` correctly.
The bug only appears in the window after updating module but before the
first execution, if a transaction calls schedule without actually
modifying the DB row.

Which was indeed happening as per discord chat:
> but yeah most likely order of event was modue was updated
> and then update_scheduled_timers_from_static_data was called

window between update module and first execution is 1 hour for this
case.


## Repo steps:
1. publish this module, it makes `send_scheduled_message` reducer to be
called every 10 secs.
```rust
#[spacetimedb::table(name = scheduled_message, public, scheduled(send_scheduled_message))]
pub struct ScheduledMessage {
    #[primary_key]
    #[auto_inc]
    scheduled_id: u64,
    scheduled_at: ScheduleAt,
}

#[spacetimedb::reducer]
fn send_scheduled_message(ctx: &ReducerContext, sched: ScheduledMessage) -> Result<(), String> {
    info!("Sending scheduled message: {:?}", ctx.timestamp);
    Ok(())
}

#[spacetimedb::reducer(init)]
pub fn init(ctx: &ReducerContext) {
    ctx.db.scheduled_message().insert(ScheduledMessage {
        scheduled_id: 0,
        scheduled_at: Duration::from_secs(10).into(),
    });
}

#[spacetimedb::reducer]
pub fn update_timer(ctx: &ReducerContext) {
    for mut timer in ctx.db.scheduled_message().iter() {
        timer.scheduled_at = Duration::from_secs(10).into();
        ctx.db.scheduled_message().scheduled_id().update(timer);
        log::info!("building decay agent timer was updated");
    }
}
```
2. Update module to support automigration (add a table) and re-publish
it.
3. Call reducer `update_timer` and do it before first execution of
`send_scheduled_message` after updating module.
4. As `update_timer` doesn't change the existing scheduler but calls
`Scheduler::schedule` it will cause duplicate entry in `DelayQueue`.


# API and ABI breaking changes
N/A

# Expected complexity level and risk
1, pretty obvious fix.

# Testing
manually.
The code fix is straightforward, but the issue only becomes visible
under specific conditions.
v1.3.1
2025-08-20 12:14:50 -07:00
Kim Altintop f7d94efb69 Fix module hotswapping for connected clients (#3159)
The `Clone` impl for `ClientConnection` would create an independent
instance that could not observe module hotswapping. This would result in
methods called on a replaced `ModuleHost` to fail, because that host
exited already.

Fix by reading the `ModuleHost` from the watch channel directly, instead
of maintaining a redundant copy.

Also fix `watch_module_host` to properly mark the current module host as
seen.

# Expected complexity level and risk

2

# Testing

- [x] test suite passes
- [x] ran @bfops repro script
2025-08-20 12:07:07 -07:00
Zeke Foppa 07ce51dca3 Reduce tools/publish-crates.sh to only publish bindings and sdk (#3180)
# Description of Changes

Fixes https://github.com/clockworklabs/SpacetimeDB/issues/3017. See that
issue for more context.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

We should do a little extra verification on the next release.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-08-20 12:06:38 -07:00
Zeke Foppa d4ef20f459 Manually apply open PR #3178: Disable column type changes in an automigration 2025-08-20 12:04:00 -07:00
Zeke Foppa e107144998 Bump versions to 1.3.0 (#3005)
# Description of Changes

Bumped all versions to 1.3.0 in preparation for an upcoming minor
release.

# API and ABI breaking changes

No breaking changes.

# Expected complexity level and risk

1

# Testing

None

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
bindings/rust/v1.3.0 sdks/typescript/v1.3.0 sdks/rust/v1.3.0 v1.3.0 bindings/csharp/v1.3.0
2025-07-30 19:16:16 +00:00
Zeke Foppa 679ebe5678 CI - C#/Unity test suite concurrency improvements (#3001)
# Description of Changes

New Unity test suite runs will cancel existing in-progress runs on the
same PR or github ref.

I tried to add a global limit of 2 test suites running at the same time,
but I did not find a successful way of making this work.

# API and ABI breaking changes

None. CI-only change.

# Expected complexity level and risk

1

# Testing
- [x] Test suite still runs and succeeds
- [x] If I push several commits in a row, previous runs get cancelled

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-29 19:05:02 +00:00
Phoebe Goldman c18b291f12 Add additional logging to subscribe route and simplify calling client_connected (#2998)
# Description of Changes

Out-of-band discussions with the BitCraft team brought up questions
about whether it was possible for a rejected client connection to start
an expensive computation like a subscription before their connection was
killed, e.g. by sending a `Subscribe` message along the WebSocket before
`client_connected` had finished returning `Err`.

I don't believe this was actually possible, as `ClientConnection::spawn`
called and awaited `call_identity_connected` before invoking its `actor`
closure, and it was that `actor` which processed `Subscribe` messages.
But it was somewhat difficult to verify that behavior, and so I
re-organized the code so that the outer layer of the `subscribe` handler
obviously had that property without having to step into
`ClientConnection::spawn`.

I also added some additional logging to the subscribe route, including
the `X-Forwarded-For` header in more messages, as the BitCraft team
complained about having difficulty correlating IP addresses with
connections. The log levels remain the same as before, just with
additional information added:

- Successful connections are at `debug` level,
- Rejected connections are at `info` level (these are the ones BitCraft
cares about in this case).
- Failed connections are at `warn`.

As the levels are unchanged, this should not add undesirable log noise.

# API and ABI breaking changes

N/a

# Expected complexity level and risk

3? The `subscribe` route was complex and remains so. I believe this
change simplifies the code and makes the logic more obvious, but
reviewers should take care to verify that the behavior actually is
equivalent as I believe.

# Testing

- [ ] I would like a test deployment of BitCraft to staging or
something, or to include this patch in the next bot test that we do
anyways, just for sanity's sake.
2025-07-29 18:29:04 +00:00
Zeke Foppa 797eea8575 CI - Monorepo tweaks (#3000)
# Description of Changes

Some small CI tweaks related to the monorepo merge.

Once we've landed these, I think we can make most of the new checks
required.

# API and ABI breaking changes

CI only changes

# Expected complexity level and risk

1

# Testing

None, just tweaked names.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-29 17:58:03 +00:00
Zeke Foppa e214f73666 TypeScript - Bump package version to 1.2.3 (#2997)
# Description of Changes

Bumping this in preparation for an upcoming release.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

None, just a version bump

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
v1.2.3-typescript
2025-07-29 03:59:43 +00:00
Zeke Foppa 81ba753f53 Bump C#/Unity Client SDK versions to 1.2.2 (#2994)
# Description of Changes

I ran `python3 tools~/upgrade-version.py 1.2.2` in preparation for an
upcoming release.

# API and ABI breaking changes

None

# Expected complexity level and risk

1
# Testing

None, just a version bump.

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
v1.2.2-csharp
2025-07-28 17:35:37 +00:00
Julien Lavocat 2227e0ff6f Add React Native support to the Typescript SDK (#2955)
This PR helps to support React Native in the Typescript SDK. We have
identified two issues:

1. Certain versions of React Native exhibit a bug where the constructor
mistakenly treats a URL object as a string. This causes an error when
the constructor attempts to call `.endsWith()` on the URL object,
leading to runtime errors. This PR adds a .toString() call when passing
a URL instance to the URL constructor.
2. React Native doesn't provide an implementation for TextEncoder and
TextDecoder which are used to read/write strings in our binary reader
and writer. This PR use introduce the usage of a library for these two
types.

Note: this still requires the use of a Polyfill as React Native URL
implementation is missing most methods in version older than 0.79 (>= 6
month old)
2025-07-28 17:08:01 +00:00
Zeke Foppa 136d5dda82 Update docs to point to SpacetimeDB monorepo (#2989)
# Description of Changes

We recently merged several repos into the SpacetimeDB repo. This PR
update the docs accordingly.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

None, just docs

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-28 15:59:43 +00:00
Mario Montoya b54a4e49b9 Add a recursion limit to the evaluation of type_expr & parse_expr (#2935)
# Description of Changes

Add a guard against `stack overflow` in case of nested expression and
`joins`.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing
- [x] Find how `deep` can be recursed the affected functions and put a
limit on it
- [x] Add a extra test to prove we can (in theory) do lots of `joins` in
the planning steps, even if executing them will be slow
2025-07-28 15:24:01 +00:00
Shubham Mishra cb174e36f6 Snapshotdir tx_offset method (#2992)
# Description of Changes
Adds a method on `SnapshotDir` to return snapshot offset.


# API and ABI breaking changes
N/A

How complicated do you think these changes are? Grade on a scale from 1
to 5,
1


# Testing
Added unit test
2025-07-28 12:43:33 +00:00
Tuan Tran 5f75c9d4d9 Generate Websocket token from auth in Unity WebGL build (#2988)
# Description of Changes

This is a fix for community bug which auth token is not used to create
Websocket connection in Unity WebGL build.
The issue here:
https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/issues/352

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [ ] Using OAuth2.0 tokens, you should get the same `Identity` even
when the token is refreshed in the WebGL build
2025-07-28 08:42:13 +00:00
Kim Altintop 8a2e9c373b smoketests: Make gathering container ports None-safe (#2991)
Python has a funny way of dealing with absent values.

Fixes (again) restart tests to handle slowly restarting containers.

# Expected complexity level and risk

1

# Testing

n/a
2025-07-28 08:31:28 +00:00
Kim Altintop 08c2a3e2fe cli: Close the websocket connection gracefully (#2925)
The `subscribe` command would drop the connection without sending a
close frame. Doing so creates a warning on the server, which can be
distracting when debugging other connections issues.


# Expected complexity level and risk

1

# Testing

Use the `subscribe` command with a local database and compare server
logs before
and after.
2025-07-28 07:49:23 +00:00
rekhoff 36f7ca2583 Adding reject-client-connections doc. (#2973)
# Description of Changes

This originally was a PR in the Docs repo:
https://github.com/clockworklabs/spacetime-docs/pull/352

This is the work portion of
https://github.com/clockworklabs/SpacetimeDBPrivate/issues/1700

This adds a "How To Reject Client Connections" guide in both Rust and C#
using the language toggle functionality.

Testing:
- [X] Validated code behavior presented in guide resulted in described
behavior.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-07-25 18:07:31 +00:00
Zeke Foppa e0ae18c99e CI - Check C# quickstart-chat bindings are up to date (#2979)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-25 17:49:27 +00:00
Zeke Foppa 6c9aebdbf3 Docs CI - Check that nav.js matches the .md files list (#2984)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-25 16:54:25 +00:00
Kim Altintop 50fd07af4d ci: Skip the Unity tests if the PR is an external contribution (#2978) 2025-07-25 04:59:13 +00:00
Alex Nemeth ce90583f6b Update quickstart-chat client module bindings from server (#2976)
Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-07-24 23:38:24 +00:00
rekhoff 62a1378153 Moved Remove operation to start of Table.Apply (#2967)
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-07-24 17:11:10 +00:00
ResuBaka 7fb4df4275 Update tungstenite to get client read performance improvement (#2966)
Co-authored-by: Kim Altintop <kim@eagain.io>
2025-07-24 17:06:43 +00:00
Kim Altintop 61b54ef723 Upgrade jemalloc_pprof and tempfile crates (#2982) 2025-07-24 15:57:57 +00:00
Zeke Foppa 79137b5016 Fix spacetime version list not showing current version (#2680)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-23 16:52:23 +00:00
Kim Altintop 6b9b0e3b81 smoketests: Fix server restarts and make more robust (#2977) 2025-07-23 15:29:43 +00:00
Kim Altintop 42905000ca smoketests: Adjust for node table rename (#2970) 2025-07-23 12:17:08 +00:00
Mazdak Farrokhzad a6552257b9 V8: add FromValue, error traits, roundtrip tests (#2971) 2025-07-22 19:07:20 +00:00
Kim Altintop 6979df59f6 ci: Temporarily disable zz_docker tests (#2974) 2025-07-22 18:24:29 +00:00
Zeke Foppa ca66340315 Disable musl builds (#2964)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-21 18:48:03 +00:00
Zeke Foppa ccc4d06ddb Update GitHub files for C#/Unity SDK (#2952)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-21 14:44:47 +00:00
Kim Altintop c43d8fe1a1 smoketest: Retry if there is no current leader (#2950) 2025-07-21 11:39:52 +00:00
Zeke Foppa bd9ea5586a Import C#/Unity SDK (#2951)
Co-authored-by: Clockwork Labs <no-reply@clockworklabs.io>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
Co-authored-by: dbrinkmanncw <109690865+dbrinkmanncw@users.noreply.github.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: SteveBoytsun <100594800+SteveBoytsun@users.noreply.github.com>
Co-authored-by: Steve <steve@codefics.com>
Co-authored-by: Alessandro Asoni <alessandro@clockworklabs.io>
Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io>
Co-authored-by: james gilles <jameshgilles@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
Co-authored-by: Kurtis Mullins <github@kurtismullins.com>
Co-authored-by: Jeremie Pelletier <jeremiep@gmail.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Steve Boytsun <steve@clockwokrlabs.io>
Co-authored-by: Ingvar Stepanyan <ingvar@clockworklabs.io>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
Co-authored-by: Noa <coolreader18@gmail.com>
Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
Co-authored-by: Daniel Kierkegaard Andersen <dax@daxode.dk>
Co-authored-by: Guribo <guribovr@gmail.com>
Co-authored-by: Lisandro Crespo <lisandroct@gmail.com>
2025-07-19 23:02:21 -07:00
Zeke Foppa 9bdb3ed52a [bfops/import-csharp]: Merge remote-tracking branch 'origin/master' into bfops/import-csharp 2025-07-18 17:10:33 -07:00
Zeke Foppa 83f52cad97 Blackholio import - README updates (#2947)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-17 17:53:48 +00:00
Zeke Foppa 07899d04d7 [bfops/import-csharp]: Merge remote-tracking branch 'origin/master' into bfops/import-csharp 2025-07-17 09:49:00 -07:00
Zeke Foppa 4115658851 Import Blackholio (#2945)
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
Co-authored-by: SteveGibson <100594800+SteveBoytsun@users.noreply.github.com>
Co-authored-by: Steve Gibson <steve@clockwokrlabs.io>
Co-authored-by: james gilles <jameshgilles@gmail.com>
Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
Co-authored-by: WeslomPo <i@weslompo.ru>
2025-07-17 09:47:40 -07:00
Zeke Foppa 7afa0b4cce Docs import - Update GitHub-related files (#2949)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-17 16:24:09 +00:00