Commit Graph

3315 Commits

Author SHA1 Message Date
Noa f22f80060f [TS] Allow brotli to be specified for compression and reorganize some websocket stuff (#4561)
# Description of Changes

[Some
runtimes](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream#browser_compatibility)
support brotli for `DecompressionStream`, so I figure we may as
well allow it. Also reorganizes some of the websocket code for better
separation of concerns.

# Expected complexity level and risk

1

# Testing

- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->
2026-04-30 02:40:29 +00:00
apron-manlike0o afa212b9db consult, prioritize event.request_id over database_update.request_id (#2729) (#3368)
Directly addresses issue #2729.

On error, the `database_update` is created by a default pattern which
always produces a `request_id` of `None`.
However the event struct holds the true `request_id`, hence it should
prioritize that request_id value.

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: apron-manlike0o <apron-manlike0o@icloud.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-30 01:37:14 +00:00
John Detter 50f5ed034e spacetime publish --yes now takes optional arguments (#4885)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

This was prompted from another request from the discord. Conversation
context:
https://discord.com/channels/1037340874172014652/1138987509834059867/1496964407278698656

We've had the ticket to make `--yes` take an enum value:
https://github.com/clockworklabs/spacetimedb/issues/3784 . Since we can
do this in a non-API/ABI breaking way we're just implementing this
ticket.

*Disclaimer: I used claude to write ~90% of this PR.*

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None. `--yes` now just takes an optional argument string that we parse,
existing CLI commands that use `--yes` will be unaffected.

# Expected complexity level and risk

1 - This is just modifying the `--yes` argument and I've included tests
in the PR.

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] `spacetime publish --yes` still works as expected
- [x] `spacetime publish --yes=all` does the same thing as `spacetime
publish --yes`
- [x] `spacetime publish --yes=remote` only skips asking if publishing
to a remote server is ok.
- [x] `spacetime publish --yes=remote` only skips asking if publishing
to a remote server is ok.
- [x] `spacetime publish --yes=migrate|remote` skips both the migrate
prompt and the remote server prompt.
- [x] new tests are passing
2026-04-30 01:13:12 +00:00
Kim Altintop e3060d2602 Confirmed database updates, take 3 (#4909)
Re-opens #4846 (#4889) again, due to new cross-repo checks
2026-04-29 11:22:08 +00:00
Rafael Guerreiro a8c8252a0b Make Timestamp a FilterableValue (#4693)
# Description of Changes
Make Timestamp a FilterableValue in Rust, C#, and Typescript. I'm not
sure this is changing all the places because we have the server and the
client in those 3 languages.

# API and ABI breaking changes
It's an additive change.

# Expected complexity level and risk
3. There are some designs decisions, like comparing timestamp to
strings/numbers.

# Testing
Added unit tests for the 3 languages.
2026-04-28 22:06:44 +00:00
james gilles 193ddfd670 WIP: Start SDK tests for delete_all_by_eq_bsatn (#2164)
# Description of Changes

This API used to be unimplemented and the SDK tests did not exercise it.
Now it is implemented but while playing with blackholio I noticed the C#
implementation was wrong.

For now I am going to fix blackholio by avoiding use of this API for
now, but we should also correct the implementation and test it.

# API and ABI breaking changes

None 

# Expected complexity level and risk

0

# Testing

Working on adding tests. If someone is more familiar with the SDK tests
I would appreciate help amending them.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-04-28 21:04:28 +00:00
clockwork-labs-bot 599496111c Fix listen_addr help default value (#4812)
# Description of Changes

Fix the `spacetime start --listen-addr` help text to match the actual
default value.

The flag already defaults to `0.0.0.0:3000`, but the help text
incorrectly said port 80.

# API and ABI breaking changes
None.

# Expected complexity level and risk
Complexity 1.

# Testing
- [x] `cargo fmt --all --check`
- [x] `cargo check -p spacetimedb-standalone`

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2026-04-28 21:04:24 +00:00
Jason Larabie fb0abc4622 Update Unreal SDK tests to work on Mac (#4861)
# Description of Changes

- Updated the Unreal SDK test harness to allow Unreal Editor to work
with MacOS
- Updated the Unreal SDK test handler to work with Nil as it's a special
case

# API and ABI breaking changes

N/A

# Expected complexity level and risk

1 - Small changes to the Unreal SDK tests

# Testing

- [x] Ran full suite of tests on Mac for Unreal SDK
- [x] Ran full suite of tests on Windows + Linux for Unreal SDK to
confirm no regression

---------

Co-authored-by: Jason Larabie <jasonlarabie@Mac.lan>
2026-04-28 15:00:21 +00:00
Kim Altintop 23eafea469 paths: fdatasync PidFile (#4890)
We do want to know the pid of the process holding the lock, so the
information should be durable.

# Expected complexity level and risk

1
2026-04-28 07:09:53 +00:00
Ryan 2063a933a9 Rekhoff/reapply update nativeaot llvm infrastructure (#4897)
# Description of Changes

Reapply changes from #4515 after reversion

# API and ABI breaking changes

No API or ABI changes

# Expected complexity level and risk

2 - This PR change itself is trivial, as it just reimplements #4515,
however as #4515 had broken the `quickstart` smoketest, this should be
considered when reviewing this PR.

# Testing

- [X] Tested against `python3 -m smoketests quickstart` locally

---------

Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2026-04-28 06:33:35 +00:00
Zeke Foppa 9e2946b2c0 Remove Python smoketests (#4896)
# Description of Changes

Remove the Python smoketests and the CI check that tests for edits.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

1

# Testing

- [ ] All CI passes

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-28 04:34:24 +00:00
Mazdak Farrokhzad 3b28744938 Re-land Replay extraction PRs (#4893)
# Description of Changes

See the corresponding commits/PRs for descriptions.

# API and ABI breaking changes

None

# Expected complexity level and risk

1 -- individual PRs already reviewed.

# Testing

No semantic changes.
2026-04-27 22:57:29 +00:00
miXin b150cf6473 align UUID reducer examples with allowed signatures (#3999)
# Description of Changes

- Corrected UUID v4/v7 reducer documentation examples to use valid
reducer signatures returning ()/Result<(), E>

# API and ABI breaking changes

- None

# Expected complexity level and risk

- 1 (doc example corrections only)

# Testing

- [ ] Not run (docs-only change)
- [ ] Please review documentation formatting and correctness

---------

Signed-off-by: miXin <52082254@qq.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-04-27 18:00:14 +00:00
DexterKoelson 4dd2d296f3 Add enabled option to useTable hook (#4721)
# Description of Changes

This adds an `enabled` option to the `useTable` hook in the React SDK,
allowing devs to conditionally disable a subscription without having to
wrap it in a component that is conditionally mounted.

With `enabled`, you can control subscription lifecycle as such:

```tsx
const [rows, isReady] = useTable(tables.messages, { enabled: isChatOpen });
```


This is a similar pattern in other data hooks (React Query's `useQuery`,
SWR, Apollo's `useSubscription`, etc).

When `enabled` is `false`:
- `computeSnapshot` returns `[[], true]` immediately (no data, ready
state)
- The subscription effect skips setup and resets `subscribeApplied`
- The event listener callback returns a no-op cleanup

When `enabled` flips back to `true`, the subscription is re-established
automatically via the dependency arrays.

# API and ABI breaking changes

None. The `enabled` field is optional and defaults to `true`, so
existing usage is unaffected.

# Expected complexity level and risk

1 — Single file change, additive only. The `enabled` flag gates existing
behavior behind early returns and is wired into the existing dependency
arrays. No interaction with other components.

# Testing I Did

- [x] Verify `useTable(tables.foo)` works as before (no `enabled` option
passed)
- [x] Verify `useTable(tables.foo, { enabled: false })` returns `[[],
true]` and does not subscribe
- [x] Verify toggling `enabled` from `false` to `true` establishes the
subscription and returns rows
- [x] Verify toggling `enabled` from `true` to `false` clears rows and
unsubscribes

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-04-27 17:52:44 +00:00
Zeke Foppa 2e01ce8046 CLI - Hide the --server-issued-login param (#4905)
# Description of Changes

Users have an odd tendency to overuse this param, which is really meant
for testing and some exceptional circumstances.

This PR hides it from the help so that it is less discoverable.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

- [x] Helptext no longer includes `--server-issued-login`

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-27 17:11:33 +00:00
Adam Christopher Smith 5164d0448f Include location in nginx config for logs specific directives (#3654)
Resolves #3652

# Description of Changes

Update docs nginx configuration to better support `spacetime logs
--follow` when self hosting configured to use ssl.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

I have added this location to my own nginx configuration and confirmed I
am able to `spacetime logs -s some-https-server <my-module> --follow`
and see logs immediately and continue following even if no log is
produced after 1 minute.

Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2026-04-27 17:07:04 +00:00
Shubham Mishra 4f2c064fe5 fix: update seq table when migrating table. (#4902)
# Description of Changes
`MutTxId::add_columns_to_table` creates new table but only copies
sequences to in-memory state, which causes `autoinc` columns to reset on
module restart.

The existing implementation relies on `create_table_and_update_seq`
helper, which only updates the sequence state in memory. This change
ensures that the `allocation` is also persisted to the system table,
keeping it consistent across restarts.

# API and ABI breaking changes
NA

# Expected complexity level and risk
2

# Testing
Added a test, which migrate table and checks for `autoinc` column value
without and with restart.

---------

Signed-off-by: Shubham Mishra <shivam828787@gmail.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2026-04-27 12:47:16 +00:00
Noa 458eac8c85 Properly handle execution time<->energy conversion in v8 host (#4884)
# Description of Changes

Fixes a todo.

# Expected complexity level and risk

1

# Testing

- [x] Checked that conversion ratio is sane.
2026-04-25 00:35:23 +00:00
Zeke Foppa 6fc591e4d5 CI - Use new internal test inputs (#4231)
# Description of Changes

Flipping on some new inputs to `Internal Tests` to get new
functionality.

I'll follow-up with a more detailed description in discord.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

2

# Testing
- [x] public PR without private PR just uses master
- [x] public PR with private PR uses that one
  - [x] fails if private PR is not approved
  - [x] fails if private PR does not pass its CI
  - [x] passes if private PR is ready to go

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-24 22:54:14 +00:00
Jeffrey Dallatezza c43439d05a Add some tests and metadata to LockedFile (#4834)
# Description of Changes

1. This adds some basic tests of `LockedFile` (which would generally
have also passed before these changes).
2. `LockedFile` can now have contents, which are added to the errors if
we can't aquire the lock. The default metadata has the pid and a
timestamp.

I now see that there is a separate `Lockfile` that doesn't clean up
locks on a crash, so that should probably also be cleaned up (but in a
separate PR).


# Expected complexity level and risk

1.

# Testing

This has unit tests.
2026-04-23 21:11:37 +00:00
Jason Larabie 44f9581487 @brougkr fix(unreal): Replace FTickableGameObject with FTSTicker (#4835)
# Description of Changes
This is a copy of #4006 with only the updates to the way Unreal handles
ticks. As per @brougkr findings:

- **FTickableGameObject initialization order bug** - Replaced with
FTSTicker for reliable tick registration:
  - Removed FTickableGameObject inheritance
  - Added FTSTicker::FDelegateHandle for manual tick registration
  - Added destructor to clean up ticker registration
  - Added OnTickerTick() method

### Issue
FTickableGameObject registers itself in its constructor BEFORE
UDbConnectionBase's constructor body runs. Even with
ETickableTickType::Never, UE's GENERATED_BODY() macro can interfere with
base class initialization order, causing the default constructor to be
called instead.

# API and ABI breaking changes

- Refactor of an underlying component of the SDK and non-breaking.

# Expected complexity level and risk

2 - This changes the structure of how the database tooling can
auto-tick, but is invisible to the developer

# Testing

As this changes a core feature I tested all aspects:
- [x] Reproduced the bug and confirmed against `master` and this branch
to see the fix working
- [x] Ran full suite of Unreal tests
- [x] Manually tested Unreal Blackholio
2026-04-23 21:06:20 +00:00
Zeke Foppa 70db721c3a Revert breaking PRs (#4881)
# Description of Changes

Revert the following PRs that have caused some breakage:
```
a32cffa76 Finish refactoring out replay (#4850)
d639be0af Replay: some code motion & reuse `ReplayCommittedState` (#4849)
78d6b6f7d Update NativeAOT-LLVM infrastructure to current ABI (#4515)
d5c1738c1 Better module backtraces for panics and whatnot (#577)
6f23b19f3 Wait for database update to become durable (#4846)
81c9eab86 Add `spacetime lock/unlock` to prevent accidental database deletion (#4502)
809aebd7c Move field `replay_table_updated` to `ReplayCommittedState` (#4807)
21b58ef99 Update axum (#2713)
b5cadff7a Extract replay stuff out of `CommittedState`, part 1 (#4804)
```

I also updated the Python smoketests for breakage introduced in
https://github.com/clockworklabs/SpacetimeDB/pull/4502. Reverting that
PR caused conflicts, so this fix is more straightforward.

# API and ABI breaking changes

Maybe kind of, but we haven't released any of these.

# Expected complexity level and risk

1

# Testing

Ask @bfops about testing

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-23 14:54:23 -07:00
Mazdak Farrokhzad adbe22b556 bindings: reuse panic message for datastore_index_scan_point_bsatn (#4876)
# Description of Changes

See tin.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Covered by existing tests.
2026-04-23 12:49:17 +00:00
Mazdak Farrokhzad a32cffa769 Finish refactoring out replay (#4850)
# Description of Changes

Move the rest of replay logic to `mod replay`.

Closes #4055.

# API and ABI breaking changes

None

# Expected complexity level and risk

2

# Testing

Just code motion.
2026-04-23 10:49:20 +00:00
Mazdak Farrokhzad 7c51914cd5 Indices: house keeping (privatize stuff + fix minor bug in insert_index) (#4782)
# Description of Changes

Index code housekeeping: Privatizes `TableIndex` fields, fixes
`insert_index` panic logic, and adds some useful helpers for future
work.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Covered by existing tests
2026-04-23 10:26:54 +00:00
Mazdak Farrokhzad e7294bf2e8 Add support for bytes key btree indices (#4733)
# Description of Changes

Add support for btree indices where the keys are encoded byte strings
for e.g., multi-column indices of no-unbounded-types (arrays and
strings) that aren't floats.

The main interesting stuff in this PR is in `bytes_key.rs` which defines
`RangeCompatBytesKey`, a type that is derived from `BytesKey`, by
converting little-endian encoded integers to big-endian. Signed integers
are now also supported, but floats are not. `table_index/mod.rs` also
includes a bunch of interesting stuff.

# API and ABI breaking changes

Technically this fixes pre-existing bugs in the handling of `Excluded`
ranges for multi-col indices.

# Expected complexity level and risk

2?

# Testing

- A proptest `order_in_bsatn_is_preserved` is now adjusted and enabled
to exercise the ordering of `RangeCompatBytesKey`.
- A proptest `btree_multi_col_range_scans_work` is added to check the
behavior of range scans on multi-col indices.

---------

Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2026-04-23 07:51:58 +00:00
Ryan 86b3ac1453 Fix SQL parser to support negative numbers in INSERT statements (#4660)
This fix is intended to resolve the community reported issue #4659

# Description of Changes
Add handling for `UnaryOperator::Minus` and `UnaryOperator::Plus` in a
new `parse_insert_value()` used during `INSERT` operations. This works
by convert negative unary expressions to signed numeric strings in
INSERT VALUES clauses.

# API and ABI breaking changes
None.

# Expected complexity level and risk
1 (Low). Localized parser fix.

# Testing
- [X] Ran local tests to verify negative numbers work in Rust,
TypeScript, and C# modules
- [X] Confirmed positive numbers and invalid expressions still work
correctly
* Testing involved running `spacetime sql module "INSERT INTO table
(col) VALUES (-100.0);"` from a CLI.

---------

Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2026-04-23 03:59:17 +00:00
Zeke Foppa 033c625eb5 Smoketests - Fix another name collision (#4873)
# Description of Changes

Similar to some changes made in
https://github.com/clockworklabs/SpacetimeDB/pull/4269.

Found another smoketest with a name collision which could cause flakes
when running against a remote server.

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

1

# Testing

- [ ] Smoketests pass

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-23 02:00:22 +00:00
Zeke Foppa 604bb3e649 CI - Move simple jobs into cargo ci (#4871)
# Description of Changes

Migrate these checks into `cargo ci`:
- Check that packages are publishable
- Docs test
- TypeScript - Tests

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

2

# Testing

- [ ] CI passes

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-23 01:13:25 +00:00
Zeke Foppa 0a08879e8a CI - cargo ci update-flow runs on Windows (#4874)
# Description of Changes

Removed some "if we're on windows" checks in the CI so that we're always
running through `cargo ci update-flow`.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

1.

# Testing

- [x] Upgrade flow tests pass

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-22 23:51:53 +00:00
Zeke Foppa 943ed7c0c7 CI - Merge workflow files (#4869)
# Description of Changes

Merged `typescript-test.yml` and `docs-test.yml` into `ci.yml`.

Note: The required checks will need to be updated when this PR is ready
to merge.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

1

# Testing

- [x] CI passes

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-22 22:16:13 +00:00
Zeke Foppa 2aa27b0dd7 CI - Move the DLL updating code into a function (#4868)
# Description of Changes

Just moving code into functions so it can be reused, no functional
changes.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

1

# Testing

None

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-22 19:35:18 +00:00
Zeke Foppa e2a74b5d1a cargo ci self-docs uses doc comments as well as explicit helptext (#4860)
# Description of Changes

Several args for `cargo ci` had empty helptext, because we were only
printing the explicitly-annotated helptext. This PR updates it so that
inline helptext also shows in the README.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

1

# Testing
- [x] Updated README has more helptext

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-22 19:04:53 +00:00
Zeke Foppa 2d67d76189 CI - Merge hooks (#4224)
# Description of Changes

Invoke a private workflow when a PR merges, so that we can do extra
follow-up actions.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

2

# Testing
- [x] When a PR merged with a corresponding private PR, I got a discord
notification:
<img width="543" height="70" alt="image"
src="https://github.com/user-attachments/assets/209347c3-57be-47d7-8d75-6154c9e222cb"
/>

- [x] When a PR merged without a corresponding private PR, no discord
notification

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-22 18:24:50 +00:00
Noa f896974b29 [TS] Implement near-heap-limit termination (#4777)
# Description of Changes

Uses `Isolate::add_near_heap_limit_callback` to prevent unbounded heap
growth. Upon nearing the heap limit, we will now:
1. Call `Isolate::terminate_execution`.
2. Request that v8 double the heap limit.

Then, upon finishing a function call, we lower the heap limit back down.

This should hopefully fix the issue where v8 hits the heap limit and
crashes the whole process.

Also improves the way termination requests are checked for and
processed.

# Expected complexity level and risk

2

# Testing

- [ ] Manual testing with memory-leaky modules
2026-04-22 17:19:26 +00:00
Zeke Foppa a7729f7dab CI - Fold typescript lint into cargo ci lint (#4856)
# Description of Changes

Merge the `TypeScript - Lint` CI job into `cargo ci lint`.

Note that this removes the custom caching for the pnpm store, but we're
planning to overhaul our CI cache approach anyway.

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

1

# Testing

- [x] Lint step passes on this PR

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-22 16:24:00 +00:00
Mazdak Farrokhzad d639be0af6 Replay: some code motion & reuse ReplayCommittedState (#4849)
# Description of Changes

First two commits are code motion.
The second commit fixes a mistake I made in a previous PR that made us
use potentially several `ReplayCommittedState`s per
`datastore.replay(..)`.

More to come in terms of PRs; stay tuned.

# API and ABI breaking changes

None

# Expected complexity level and risk

3
2026-04-22 11:23:06 +00:00
joshua-spacetime 91494c9cf2 Keep subscription fanout worker warm with adaptive linger policy (#4805)
# Description of Changes

Similar to https://github.com/clockworklabs/SpacetimeDB/pull/4801, after
we evaluate subscriptions on the main database thread, we send the
results to a worker whose job it is to fan out the updates for the
relevant clients. Hence we want to make sure this worker is not
constantly parked on `recv()` as each `send` on the main thread will
incur overhead waking the task.

To avoid this I've added a utility that wraps an `mpsc`
`UnboundedReceiver` with an adaptive "linger" policy. On each message
`recv`, the worker will now "linger" for a period of time and wait for
any more messages before parking itself on the `recv()` again.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

Manual performance testing for now. Automation to follow.
2026-04-22 01:21:44 +00:00
Tyler Cloutier 78d6b6f7dd Update NativeAOT-LLVM infrastructure to current ABI (#4515)
## Summary

- Update the experimental NativeAOT-LLVM build path
(`EXPERIMENTAL_WASM_AOT=1`) to include all host function imports from
ABI versions 10.0 through 10.4
- Fix the compiler package reference to work on both Windows x64 and
Linux x64 (was hardcoded to Windows only)
- Add a CI smoketest to verify AOT builds work on Linux x64

## Context

See #4514 for the full writeup on the C# AOT situation. The
`wasi-experimental` workload that all C# module builds depend on is
deprecated and removed from .NET 9+. NativeAOT-LLVM is the recommended
path forward for ahead-of-time compilation of C# to WebAssembly.

The existing NativeAOT-LLVM support (added by RReverser in #713) was
stale: missing imports added since then and a Windows-only package
reference.

## Changes

**`SpacetimeDB.Runtime.targets`:**
- Add 10 missing `WasmImport` declarations across spacetime_10.0 through
10.4
- Replace `runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM` with
`runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM`
so it resolves correctly on Linux x64 as well
- Use explicit version strings instead of the `$(SpacetimeNamespace)`
variable

**`ci.yml`:**
- Add AOT build smoketest step in the `csharp-testsuite` job

## Test plan

- [x] CI smoketest passes: `EXPERIMENTAL_WASM_AOT=1 dotnet publish -c
Release` builds successfully on Linux x64
- [ ] Existing C# tests continue to pass (no changes to the default
interpreter path)

---------

Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
Co-authored-by: Ryan <r.ekhoff@clockworklabs.io>
Co-authored-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2026-04-21 21:47:16 +00:00
DexterKoelson 59ac77970f Add useProcedure React hook and export procedures from codegen (#4752)
Closes #4751

# Description of Changes
- Add `useProcedure` React hook that mirrors `useReducer` which returns
a stable, typed callback that queues calls until the connection is ready
- Add `ProcedureParamsType` and `ProcedureReturnType` utility types to
`type_utils.ts`
- Update TypeScript codegen to emit `export const procedures =
__convertToAccessorMap(proceduresSchema.procedures)` in generated module
bindings, matching the existing pattern for reducers

```ts
import { procedures } from './module_bindings';
import { useProcedure } from 'spacetimedb/react';

const doSomeThing = useProcedure(procedures.doSomeThing);
const result = await doSomeThing({ foo: "..." });
```

# API and ABI breaking changes
None. Additive only — new hook export and new codegen line.

# Expected complexity level and risk
Low. The hook is a near-copy of `useReducer` adapted for procedure
signatures. The codegen change adds one line following the identical
pattern used for reducers.

# Testing
- [x] TypeScript SDK compiles with no new errors (`tsc --noEmit`)
- [x] All 170 existing tests pass (17 test files)
- [x] Tested end-to-end in a React app calling a procedure

---------

Co-authored-by: Jason Larabie <jason@clockworklabs.io>
2026-04-21 21:06:06 +00:00
Ryan 649e0a8379 Add sdk-test-procedure-cs test module (#4840)
# Description of Changes

Adds a `sdk-test-procedure-cs` test to the other test modules in
`sdks/rust/tests/test.rs`.
Functionally `sdk-test-procedure-cs` performs all the operations as the
Rust test `sdk-test-procedure` but through C#, fulfilling the
requirements of Issue #3951

# API and ABI breaking changes

No API or ABI changes, this only adds a test.

# Expected complexity level and risk

1

# Testing

- [X] Ran `cargo test -p spacetimedb-sdk csharp_procedures` locally
without errors.
2026-04-21 21:06:04 +00:00
Zeke Foppa ea834acb79 CI - move pnpm build into cargo ci test (#4855)
# Description of Changes

To make `cargo ci test` more properly include the full test logic.

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

1

# Testing

honestly none

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-21 20:23:07 +00:00
Zeke Foppa 1c10afea0b CI - Move the git diff check under cargo ci smoketests (#4854)
# Description of Changes

To make `cargo ci` more properly the full test logic.

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

1

# Testing

honestly none

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-21 20:10:40 +00:00
Zeke Foppa 0cbf4dc5c8 Add cargo lint as alias for cargo ci lint (#4853)
# Description of Changes

Just a one-line alias as requested

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

`cargo lint` properly runs `cargo ci lint`.

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2026-04-21 19:19:00 +00:00
Noa d5c1738c15 Better module backtraces for panics and whatnot (#577)
# Description of Changes


![image](https://github.com/clockworklabs/SpacetimeDB/assets/33094578/9c6356af-9b34-462a-8441-8bd859a73b86)

If these symbols aren't in the stack, it does no processing

# Expected complexity level and risk

1 - it's pretty self-contained, and backwards-compatible with the
existing logs data format

---------

Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-04-21 13:08:57 +00:00
Jason Larabie f1fe5db95a Update the defaultValue check to allow for falsy and undefined values (#4838)
# Description of Changes

This fixes a bug in TypeScript table default serialization where falsy
defaults like 0, '', false, and explicit undefined were treated as if no
default was provided. I did this as a property check in order to allow
`undefined` which becomes None() as the API allows `T | undefined`.

Closes: #4700 

# API and ABI breaking changes

N/A 

# Expected complexity level and risk

1 - Simple change to check the default value was added as a property

# Testing

- [x] Reproduced the failing issue in a simple throwaway project
2026-04-21 13:08:54 +00:00
Kim Altintop 6f23b19f36 Wait for database update to become durable (#4846)
Confirmed reads applies only to subscription clients, calls to the the
HTTP API publish endpoint return a success response before the operation
is confirmed.

While we await scheduling of a new database, updates require to wait for
the update transaction to be confirmed. To allow this, the
`TransactionOffset` channel and the database's `DurableOffset` need to
be returned all the way up to the request handler.

Note that waiting for confirmation is almost always the right choice, so
can't be opted out of at the time of submission of this patch. Callers
may, however, extend the timeout after which waiting for confirmation is
cancelled.
2026-04-21 07:58:57 +00:00
Ryan af37985a4d Adds a non-repeating scheduled reducer test (#3233)
# Description of Changes

Adds a non-repeating scheduled reducer integration test to the existing
Rust and C# integration tests, in order to address #3213

# API and ABI breaking changes

No

# Expected complexity level and risk

1

# Testing

- [X] Ran `cargo test -p spacetimedb-testing` and all tests passed

---------

Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
2026-04-20 23:19:04 +00:00
clockwork-labs-bot 81c9eab86c Add spacetime lock/unlock to prevent accidental database deletion (#4502)
## Motivation

Feature request: "Is there any way we can lock a module to prevent it
from being deleted? A bit concerned about some fat finger risk of
accidentally deleting prod."

## Solution

Adds a database lock mechanism. A locked database cannot be deleted
until explicitly unlocked.

### New CLI Commands

```bash
# Lock a database to prevent deletion
spacetime lock my-database

# Attempt to delete a locked database (fails with 403)
spacetime delete my-database
# Error: Database is locked and cannot be deleted. Run \`spacetime unlock\` first.

# Unlock when you actually need to delete
spacetime unlock my-database
spacetime delete my-database
```

Both commands support `--server` and `--no-config` flags, and resolve
the database from `spacetime.json` when no argument is given (same as
`spacetime delete`).

### New HTTP API

- `POST /v1/database/:name_or_identity/lock` -- Lock a database
- `POST /v1/database/:name_or_identity/unlock` -- Unlock a database

Both require the same authorization as `DELETE` (owner only).

### Implementation

- Lock state stored in a separate `database_locks` sled tree in the
standalone control DB (avoids changing the `Database` struct and needing
a data migration)
- `ControlStateReadAccess::is_database_locked()` and
`ControlStateWriteAccess::set_database_lock()` added to the trait
- `delete_database` route checks lock state before proceeding; returns
`403 Forbidden` with a descriptive message if locked
- Locking is idempotent (locking an already-locked database is a no-op,
same for unlock)
- Lock only prevents deletion, not publishing updates

### What is NOT locked

- `spacetime publish` (updating module code) still works on locked
databases
- Only `spacetime delete` is blocked

This matches the intent: protect prod from accidental destruction while
allowing normal deployments.

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-04-20 21:03:15 +00:00
Piotr Sarnacki 7726fe807a Add a test for #1121 (#1125)
# Description of Changes

While working on #1111 I realised that we have a bug with subscriptions
not being unique when multiple clients with the same identity are
connected. I fixed the bug and only then realised it was already fixed
yesterday in #1121. When working on my changes I created a test for the
issue, so I guess it doesn't hurt to at least submit it.

# Expected complexity level and risk

1

---------

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
2026-04-17 21:51:40 +00:00