clockworklabs/SpacetimeDB · error · Error

Table does not exist

Error message

Table ${String(name)} does not exist

What it means

ClientCache.getTable looks up a per-client map of table caches that is populated by registerTable/registerTables. On a miss it logs a console.error explaining registration ordering and then throws 'Table <name> does not exist'. getOrCreateTable is the non-throwing create-on-demand variant.

Solutions

  1. Await the generated registerTable/registerTables calls (and connection) before any getTable or subscription
  2. Verify the name against the generated RemoteModule table list; typed mode turns typos into compile errors
  3. Check client.cache.tables.has(name) before access, or use getOrCreateTable when create-on-demand is intended

Example fix

// before
const players = conn.cache.getTable('players'); // registration still in flight

// after
await registrationDone; // generated registerTable() calls finished
const players = conn.cache.getTable('players');
Defensive patterns

Strategy: validation

Validate before calling

if (!conn.cache.tables.has(tableName)) {
  throw new Error(`table '${tableName}' not registered yet; await registerTable/registerTables first`);
}
const cache = conn.cache.getTable(tableName);

Prevention

When it happens

Trigger: Calling client.cache.getTable('players') before the generated registerTable/registerTables call(s) completed (missing await); with a typo'd or renamed table name; or in untyped mode passing any arbitrary string that was never registered.

Common situations: Race between connection setup and a subscription/UI read firing first; module renamed a table while the client keeps stale generated bindings; copy-paste table names with wrong casing; a code path that skips registration in one entry point.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20). Data as JSON: /api/errors/f077e4cac903108e. Report an issue: GitHub.

Appendix: source

Thrown at crates/bindings-typescript/src/sdk/client_cache.ts:102

   * The tables in the database.
   */
  readonly tables = new TableMap<RemoteModule>();

  /**
   * Returns the table with the given name.
   * - If SchemaDef is a concrete schema, `name` is constrained to known table names,
   *   and the return type matches that table.
   * - If SchemaDef is undefined, `name` is string and the return type is untyped.
   */
  getTable<N extends TableName<RemoteModule>>(
    name: N
  ): TableCacheForTableName<RemoteModule, N> {
    const table = this.tables.get(name);
    if (!table) {
      console.error(
        'The table has not been registered for this client. Please register the table before using it. If you have registered global tables using the SpacetimeDBClient.registerTables() or `registerTable()` method, please make sure that is executed first!'
      );
      throw new Error(`Table ${String(name)} does not exist`);
    }
    return table;
  }

  /**
   * Returns the table with the given name, creating it if needed.
   * - Typed mode: `tableTypeInfo.tableName` is constrained to known names and
   *   the return type matches that table.
   * - Untyped mode: accepts any string and returns an untyped TableCache.
   */
  getOrCreateTable<N extends TableName<RemoteModule>>(
    tableDef: TableDefForTableName<RemoteModule, N>
  ): TableCacheForTableName<RemoteModule, N> {
    const name = tableDef.accessorName;

    const table = this.tables.get(name);
    if (table) {
      return table;

View on GitHub (pinned to 6dee26c6ef)