clockworklabs / clockworklabs/SpacetimeDB
`generate` and `dev` emit an unloadable module with wasm-opt 132
@coolreader18 is already working on this.
Since Aug 27, 2026.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
Summary
wasm-opt 132 added the compact import section encoding and turns it on under -all.
spacetime build runs wasm-opt -all -g -O2, so the optimised module now uses that encoding and
spacetimedb can no longer parse it. Disabling the feature fixes it.
Repro
$ wasm-opt --version
wasm-opt version 132
$ spacetime --version
spacetimedb tool version 2.8.2; spacetimedb-lib version 2.8.2;
$ spacetime init compact-repro -t basic-rs --non-interactive --local
$ cd compact-repro
$ spacetime dev compact-repro --server-only -y
Compiling compact_repro v0.1.0 (.../compact-repro/spacetimedb)
Finished `release` profile [optimized] target(s) in 14.40s
Optimising module with wasm-opt...
Build complete!
Publishing...
Publishing module .../compact-repro/spacetimedb to database 'compact-repro'
Optimising module with wasm-opt...
Build finished successfully.
Uploading to http://127.0.0.1:3000 => http://127.0.0.1:3000
Checking for breaking changes...
Publishing module...
Error: failed to parse WebAssembly module: invalid leading byte (0x7e) for external kind (at offset 0xb4)
Caused by:
HTTP status server error (500 Internal Server Error) for url (http://127.0.0.1:3000/v1/database/compact-repro?host_type=Wasm)
spacetime generate fails the same way, and needs no server at all:
$ spacetime generate --lang rust --out-dir src/module_bindings --module-path spacetimedb
Generating Rust module bindings for module spacetimedb
Optimising module with wasm-opt...
Build finished successfully.
Error: failed to parse WebAssembly module
Caused by:
invalid leading byte (0x7e) for external kind (at offset 0xb4)
Error: could not extract schema
Caused by:
EOF while parsing a value at line 1 column 0
The reported byte and offset vary by module. Both 0x7e and 0x7f occur, depending on whether a
group of imports shares just its module name or its type as well.
Cause
crates/cli/src/tasks/mod.rs:
match cmd!("wasm-opt", "-all", "-g", "-O2", &wasm_path, "-o", &wasm_path_opt).run() {
-all turns on every Binaryen feature, which as of version 132 includes compact-imports. The
re-encoded import section then fails to parse in wasmtime 39 (wasmparser 0.240), which is what
loads the module in both cases above: generate via spacetimedb-standalone extract-schema, and
publish via the server's publish route.
Suggested fix
Either add --disable-compact-imports after -all if version 132 is detected, or remove -all and specify the needed features.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.