clockworklabs/SpacetimeDB · critical · RangeError

unknown anonViewId ${id}

Error message

unknown anonViewId ${id}

What it means

Anonymous views (callable without a caller identity) are dispatched by numeric id against the flattened anonViewFns arrays of the module and its submodules. If the id is outside every submodule's range, dispatch throws RangeError('unknown anonViewId <n>'): the host's idea of the anonymous-view table does not match the deployed module.

Source

Thrown at crates/bindings-typescript/src/server/runtime.ts:674

      localId = id;
      dbView = this.#dbView as ReadonlyDbView<any>;
      from = makeQueryBuilder(moduleCtx.schemaType);
    } else {
      let offset = this.#consumerAnonViewCount;
      let found = false;
      for (let i = 0; i < this.#flatSubmodules.length; i++) {
        const m = this.#flatSubmodules[i];
        if (id < offset + m.anonViewFns.length) {
          anonViewFns = m.anonViewFns;
          localId = id - offset;
          dbView = this.#getSubmoduleDbView(i) as ReadonlyDbView<any>;
          from = this.#getSubmoduleQueryBuilder(i);
          found = true;
          break;
        }
        offset += m.anonViewFns.length;
      }
      if (!found) throw new RangeError(`unknown anonViewId ${id}`);
    }

    const { fn, deserializeParams, serializeReturn, returnTypeBaseSize } =
      anonViewFns![localId!];
    const ctx: AnonymousViewCtx<any> = freeze({
      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

  1. Redeploy the module and regenerate all bindings so anonymous-view ids match
  2. Only append new anonymous views between deploys; never reorder or remove existing ones
  3. Align host/SDK versions and confirm the deployed module hash matches what you generated against
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: The host calls an anonymous view id that was removed or reordered by a redeploy; submodule anonymous-view sets differ between the host's build and the deployed module.

Common situations: Redeploying with changed anonymous views while stale host state or old generated bindings persist; version skew between host and module toolchain.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/abef82a7a13777cf. Report an issue: GitHub.