{"record":{"id":"f077e4cac903108e","repo":"clockworklabs/SpacetimeDB","slug":"table-string-name-does-not-exist","errorCode":null,"errorMessage":"Table ${String(name)} does not exist","messagePattern":"Table (.+?) does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/sdk/client_cache.ts","lineNumber":102,"sourceCode":"   * The tables in the database.\n   */\n  readonly tables = new TableMap<RemoteModule>();\n\n  /**\n   * Returns the table with the given name.\n   * - If SchemaDef is a concrete schema, `name` is constrained to known table names,\n   *   and the return type matches that table.\n   * - If SchemaDef is undefined, `name` is string and the return type is untyped.\n   */\n  getTable<N extends TableName<RemoteModule>>(\n    name: N\n  ): TableCacheForTableName<RemoteModule, N> {\n    const table = this.tables.get(name);\n    if (!table) {\n      console.error(\n        '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!'\n      );\n      throw new Error(`Table ${String(name)} does not exist`);\n    }\n    return table;\n  }\n\n  /**\n   * Returns the table with the given name, creating it if needed.\n   * - Typed mode: `tableTypeInfo.tableName` is constrained to known names and\n   *   the return type matches that table.\n   * - Untyped mode: accepts any string and returns an untyped TableCache.\n   */\n  getOrCreateTable<N extends TableName<RemoteModule>>(\n    tableDef: TableDefForTableName<RemoteModule, N>\n  ): TableCacheForTableName<RemoteModule, N> {\n    const name = tableDef.accessorName;\n\n    const table = this.tables.get(name);\n    if (table) {\n      return table;","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-typescript/src/sdk/client_cache.ts#L84-L120","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Await the generated registerTable/registerTables calls (and connection) before any getTable or subscription","Verify the name against the generated RemoteModule table list; typed mode turns typos into compile errors","Check client.cache.tables.has(name) before access, or use getOrCreateTable when create-on-demand is intended"],"exampleFix":"// before\nconst players = conn.cache.getTable('players'); // registration still in flight\n\n// after\nawait registrationDone; // generated registerTable() calls finished\nconst players = conn.cache.getTable('players');","handlingStrategy":"validation","validationCode":"if (!conn.cache.tables.has(tableName)) {\n  throw new Error(`table '${tableName}' not registered yet; await registerTable/registerTables first`);\n}\nconst cache = conn.cache.getTable(tableName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Await generated registerTable/registerTables (and connection) before any table access","Prefer typed mode so unknown table names fail at compile time","Use getOrCreateTable when create-on-demand is the intended behavior"],"tags":["table","cache","registration","typescript"],"backgroundTag":"table-not-registered","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}