clockworklabs / clockworklabs/SpacetimeDB

TypeScript SDK - Bug: If project sources are minified, the wrong table/reducer class name is registered

Open
#3,039 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

possibly-stale
Dominant language
Rust
Stars
25.2k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
46

Description

The issue is that the registerTables and registerReducers methods rely on the .name attribute of the generated classes in the bindings. I'd recommend to use .tableName (I'm not sure though if that suitable) or add a separate static field .className instead of relying on JavaScript sources that may change during bundling and minification.

Ib my case, I'm configuring the Spacetime SDK in a Next.js project which has code minification enabled, and the class names in the bindings are mangled which causes missing class error:

Uncaught (in promise) Could not find class "World", you need to register it with SpacetimeDBClient.registerTable() first

CleanShot 2023-12-31 at 14 48 13@2x

CleanShot 2023-12-31 at 14 50 09@2x

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript SDK entry points named registerTables and registerReducers, then inspect how generated binding classes provide their names. Reproduce the issue with a minified Next.js build and confirm that table and reducer registration no longer depends on mangled JavaScript class names.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.