-
Notifications
You must be signed in to change notification settings - Fork 664
Closed
Description
Using spacetimedb 1.9.0
const a = table(
{ name: 'A' },
{ id: t.u32().primaryKey().autoInc() }
);
const b = table(
{ name: 'B' },
{ id: t.string().primaryKey() }
);
const c = table(
{ name: 'C' },
{
id: t.u32().primaryKey().autoInc()
aId: t.u32(),
bId: t.string(),
}
);
const db = schema(a, b, c);
✅ Works
db.init(ctx => {
const { id: aId } = ctx.db.A.insert({ id: 0 });
const bId = 'B_ID';
ctx.db.B.insert({ id: bId });
ctx.db.C.insert({ id: 0, aId, bId });
});
db.init(ctx => {
const { id: aId } = ctx.db.A.insert({ id: 0 });
const { id: bId } = ctx.db.B.insert({ id: 'B_ID' });
ctx.db.C.insert({ id: 0, aId, bId: 'B_ID' });
});
❌ Fails
db.init(ctx => {
const { id: aId } = ctx.db.A.insert({ id: 0 });
const { id: bId } = ctx.db.B.insert({ id: 'B_ID' });
ctx.db.C.insert({ id: 0, aId, bId });
});
DB logs
2025-11-26T16:14:42.210906Z INFO crates\core\src\host\v8\error.rs:401: reducer "init" runtime error: js error Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at F (spacetimedb_module:181:26)
at v.encode (spacetimedb_module:215:49)
at writeString (spacetimedb_module:480:43)
at serializeValue (spacetimedb_module:1029:12)
at serializeValue (spacetimedb_module:1097:54)
at serializeValue (spacetimedb_module:970:20)
at insert (spacetimedb_module:3677:20)
at <anonymous> (spacetimedb_module:4223:21)
at __call_reducer__ (spacetimedb_module:3615:30)
2025-11-26T16:14:42.211313Z INFO crates\core\src\host\v8\error.rs:403: js error Uncaught TypeError: Cannot read properties of undefined (reading 'length')
2025-11-26T16:14:42.211619Z INFO crates\core\src\host\v8\error.rs:405: Frame #0: at F (spacetimedb_module:181:26)
2025-11-26T16:14:42.211849Z INFO crates\core\src\host\v8\error.rs:405: Frame #1: at v.encode (spacetimedb_module:215:49)
2025-11-26T16:14:42.212099Z INFO crates\core\src\host\v8\error.rs:405: Frame #2: at writeString (spacetimedb_module:480:43)
2025-11-26T16:14:42.212333Z INFO crates\core\src\host\v8\error.rs:405: Frame #3: at serializeValue (spacetimedb_module:1029:12)
2025-11-26T16:14:42.212558Z INFO crates\core\src\host\v8\error.rs:405: Frame #4: at serializeValue (spacetimedb_module:1097:54)
2025-11-26T16:14:42.212785Z INFO crates\core\src\host\v8\error.rs:405: Frame #5: at serializeValue (spacetimedb_module:970:20)
2025-11-26T16:14:42.213014Z INFO crates\core\src\host\v8\error.rs:405: Frame #6: at insert (spacetimedb_module:3677:20)
2025-11-26T16:14:42.213192Z INFO crates\core\src\host\v8\error.rs:405: Frame #7: at <anonymous> (spacetimedb_module:4223:21)
2025-11-26T16:14:42.213357Z INFO crates\core\src\host\v8\error.rs:405: Frame #8: at __call_reducer__ (spacetimedb_module:3615:30)
2025-11-26T16:14:42.214702Z ERROR D:\a\SpacetimeDB\SpacetimeDB\crates\client-api\src\lib.rs:546: internal error: The instance encountered a fatal error.
cli publish logs
Publishing module...
JavaScript / TypeScript support is currently in BETA.
There may be bugs. Please file issues if you encounter any.
<https://github.com/clockworklabs/SpacetimeDB/issues/new>
Error: The instance encountered a fatal error.
Caused by:
HTTP status server error (500 Internal Server Error) for url (http://127.0.0.1:3000/v1/database/entourage-server?clear=true&host_type=Js)
Notice the error doesn't happen with aId, which is a number.
Metadata
Metadata
Assignees
Labels
No labels