{"record":{"id":"ba6667950c8033da","repo":"clockworklabs/SpacetimeDB","slug":"unknown-viewid-id","errorCode":null,"errorMessage":"unknown viewId ${id}","messagePattern":"unknown viewId (.+?)","errorType":"exception","errorClass":"RangeError","httpStatus":null,"severity":"critical","filePath":"crates/bindings-typescript/src/server/runtime.ts","lineNumber":624,"sourceCode":"      localId = id;\n      dbView = this.#dbView as ReadonlyDbView<any>;\n      from = makeQueryBuilder(moduleCtx.schemaType);\n    } else {\n      let offset = this.#consumerViewCount;\n      let found = false;\n      for (let i = 0; i < this.#flatSubmodules.length; i++) {\n        const m = this.#flatSubmodules[i];\n        if (id < offset + m.viewFns.length) {\n          viewFns = m.viewFns;\n          localId = id - offset;\n          dbView = this.#getSubmoduleDbView(i) as ReadonlyDbView<any>;\n          from = this.#getSubmoduleQueryBuilder(i);\n          found = true;\n          break;\n        }\n        offset += m.viewFns.length;\n      }\n      if (!found) throw new RangeError(`unknown viewId ${id}`);\n    }\n\n    const { fn, deserializeParams, serializeReturn, returnTypeBaseSize } =\n      viewFns![localId!];\n    const ctx: ViewCtx<any> = freeze({\n      sender: new Identity(sender),\n      db: dbView!,\n      from: from!,\n    });\n    const args = deserializeParams(new BinaryReader(argsBuf));\n    const ret = callUserFunction(fn, ctx, args);\n    const retBuf = new BinaryWriter(returnTypeBaseSize);\n    if (isRowTypedQuery(ret)) {\n      const query = toSql(ret);\n      ViewResultHeader.serialize(retBuf, ViewResultHeader.RawSql(query));\n    } else {\n      ViewResultHeader.serialize(retBuf, ViewResultHeader.RowData);\n      serializeReturn(retBuf, ret);","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-typescript/src/server/runtime.ts#L606-L642","documentation":"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.","triggerScenarios":"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.","commonSituations":"Schema changes (dropped or reordered views) redeployed while host state or generated bindings still reference old ids; hosttools/SDK/server version skew.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["dispatch","schema-mismatch","view","typescript"],"backgroundTag":"unknown-dispatch-id","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}