Skip to content

fix(bindings-typescript): support cross-bundle Range instances in index scans (#6299) - #6350

Open
Tyagiquamar wants to merge 1 commit into
clockworklabs:masterfrom
Tyagiquamar:fix/ts-range-instanceof-test-utils-6299
Open

Tyagiquamar wants to merge 1 commit into
clockworklabs:masterfrom
Tyagiquamar:fix/ts-range-instanceof-test-utils-6299

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description of Changes

Fixes #6299.

When using spacetimedb/server/test-utils or module code bundled across entrypoints, filtering or deleting through a table index using a Range instance failed because range instanceof Range evaluated to false.

dist/server/test-utils/index.mjs and dist/server/index.mjs are separate bundles, each inlining its own copy of Range. Consequently:

  1. range instanceof Range evaluates to false across bundles.

  2. The runtime falls back to serializing the Range object as a single point.

  3. On number columns, index scans match no rows. On BigInt-backed columns (like Timestamp), the point serializer throws TypeError: Cannot convert undefined to a BigInt.

  4. Added Symbol.for('spacetimedb.Range') brand to Range.prototype and added Range.isRange(val) / exported isRange(val) predicate.

  5. In crates/bindings-typescript/src/server/runtime.ts, replaced instanceof Range checks in single-column index filter/delete and multi-column index scan paths with isRange(...).

  6. Added unit and regression tests in crates/bindings-typescript/tests/index_prefix_filter.test.ts verifying that cross-bundle Range instances work seamlessly for both single-column and multi-column btree index filters and deletes.

API and ABI breaking changes

None. Adds Range.isRange and exports isRange without breaking existing signatures.

Rollback safety impact

n/a

Expected complexity level and risk

  1. Small, localized change in crates/bindings-typescript/src/server/ (range.ts, index.ts, runtime.ts) plus unit tests.

Testing

  • vitest run tests/index_prefix_filter.test.ts: 11 tests passed.
  • tsc -p tsconfig.build.json --noEmit: passed.

@Tyagiquamar
Tyagiquamar force-pushed the fix/ts-range-instanceof-test-utils-6299 branch from 9261fdc to 43794ca Compare November 27, 2026 04:09

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module test harness: index range scans match nothing, or throw, because Range fails instanceof

1 participant