clockworklabs/SpacetimeDB · critical · RangeError
unknown viewId ${id}
Error message
unknown viewId ${id} What it means
When the host calls a (non-anonymous) view, the runtime resolves the numeric viewId against the flattened viewFns arrays of the root module and submodules. An id outside every range throws RangeError('unknown viewId <n>'), meaning the host and deployed module disagree about the view dispatch table.
Source
Thrown at crates/bindings-typescript/src/server/runtime.ts:624
localId = id;
dbView = this.#dbView as ReadonlyDbView<any>;
from = makeQueryBuilder(moduleCtx.schemaType);
} else {
let offset = this.#consumerViewCount;
let found = false;
for (let i = 0; i < this.#flatSubmodules.length; i++) {
const m = this.#flatSubmodules[i];
if (id < offset + m.viewFns.length) {
viewFns = m.viewFns;
localId = id - offset;
dbView = this.#getSubmoduleDbView(i) as ReadonlyDbView<any>;
from = this.#getSubmoduleQueryBuilder(i);
found = true;
break;
}
offset += m.viewFns.length;
}
if (!found) throw new RangeError(`unknown viewId ${id}`);
}
const { fn, deserializeParams, serializeReturn, returnTypeBaseSize } =
viewFns![localId!];
const ctx: ViewCtx<any> = freeze({
sender: new Identity(sender),
db: dbView!,
from: from!,
});
const args = deserializeParams(new BinaryReader(argsBuf));
const ret = callUserFunction(fn, ctx, args);
const retBuf = new BinaryWriter(returnTypeBaseSize);
if (isRowTypedQuery(ret)) {
const query = toSql(ret);
ViewResultHeader.serialize(retBuf, ViewResultHeader.RawSql(query));
} else {
ViewResultHeader.serialize(retBuf, ViewResultHeader.RowData);
serializeReturn(retBuf, ret);View on GitHub (pinned to 524b4487d9)
Solutions
- Redeploy the module and regenerate bindings so view ids match on both sides
- Add views instead of reordering/removing them between deploys
- Align spacetimedb host, hosttools and SDK versions, and verify the deployed module hash
Defensive patterns
Strategy: validation
Prevention
- Only append new views between deploys; do not reorder or remove existing ones
- Regenerate all bindings after schema changes and redeploy before serving traffic
- Verify module hash and host version match after every deploy in your release checklist
When it happens
Trigger: The host dispatches a view id that no longer exists after the module was redeployed with views removed/reordered; submodule view sets differ between the build the host knows and the deployed one.
Common situations: Schema changes (dropped or reordered views) redeployed while host state or generated bindings still reference old ids; hosttools/SDK/server version skew.
Related errors
- unknown anonViewId ${id}
- unknown reducerId ${reducerId}
- unknown procedureId ${id}
- cannot serialize refs without a typespace
- cannot deserialize refs without a typespace
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/ba6667950c8033da.
Report an issue: GitHub.