Skip to content

JS runtime 2.0.4 derives internal index names from accessor keys instead of canonical schema names, causing "No such index" panics after publish #4701

@johannesvuorinen

Description

@johannesvuorinen

We hit a runtime bug in the JS spacetimedb package (2.0.4) that breaks published databases with existing snake_case schemas.

Symptom

  • spacetime publish succeeds
  • the new instance then fatally crashes on first reducer call
  • subsequent CLI calls fail with 403 / The instance encountered a fatal error
  • logs show panics like Uncaught No such index

What we observed

It looks like internal runtime index/source names are being derived from JS accessor keys instead of canonical table/column names.

Example:

  • table accessor: cardDetails
  • field/accessor: nameKey
  • runtime expected:
    • cardDetails_nameKey_idx_btree
  • actual published DB index name:
    • card_details_name_key_idx_btree

Another example:

  • runtime expected:
    • runtimeIslandStates_ownerId_idx_btree
  • actual DB index name:
    • runtime_island_states_owner_id_idx_btree

So the runtime looks up a non-existent index and panics.

Why we think this is the cause

We patched the installed runtime in node_modules/spacetimedb/dist/server/index.mjs with these two changes:

  1. Use canonical column names when building the index column list
colNameList.push(row.row[elem.name]?.columnMetadata?.name ?? elem.name);

instead of:

colNameList.push(elem.name);

2. Use canonical table name instead of accessor name when building index source names

const sourceName = index.sourceName = `${tableName}_${colS}_idx_${index.algorithm.tag.toLowerCase()}`;

instead of:

const sourceName = index.sourceName = `${accName}_${colS}_idx_${index.algorithm.tag.toLowerCase()}`;

After that patch:

- reducer calls stopped panicking
- config reducers like set_storage_config worked again
- runtime smoke tests passed on both staging and live published databases

## Environment

- spacetimedb CLI/runtime version 2.0.4

## Expected behavior

Runtime index/source-name resolution should be based on canonical schema names, not JS accessor identifiers.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions