Skip to content

chore(rivetkit): remove wasm sqlite runtime#4614

Draft
NathanFlurry wants to merge 1 commit intomainfrom
chore/remove-wasm-sqlite-native-only
Draft

chore(rivetkit): remove wasm sqlite runtime#4614
NathanFlurry wants to merge 1 commit intomainfrom
chore/remove-wasm-sqlite-native-only

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 12, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 12, 2026

PR Review: chore(rivetkit): remove wasm sqlite runtime

This is a substantial simplification (+877 / -11,318). The direction is correct: eliminating the WASM/KV-backed SQLite path removes a large amount of complexity and aligns with the fail-by-default principle in CLAUDE.md. Notes below.


Bugs

1. Cache entry leak on bridge error in index.cts

In dynamic-isolate-runtime/src/index.cts, createNativeDatabaseBridge deletes from the cache after the bridge call. If bridgeCall throws, the stale entry remains in nativeDatabaseCache. A subsequent open() call returns the broken handle instead of a fresh one. By contrast, isolate-runtime.ts dbCloseRef correctly deletes before calling close(). Apply the same order here.

2. bigint precision loss in native-database.ts

SQLite INTEGER is 64-bit. Number(bigint) is lossy for values outside +/-(2^53-1). Row IDs, epoch timestamps stored as integers, and user-defined 64-bit values can silently lose precision. Either add a safe-integer guard and throw, or change the native binding to accept a string/bigint representation. At minimum, add a comment documenting this boundary.

3. Stale column names for multi-statement exec in isolate-runtime.ts

For a multi-statement DDL/query string, columns ends up holding the column names from the last result set only. The rows from earlier statements are associated with the wrong column names. Low impact because exec is DDL-only in practice, but worth fixing for correctness.


Style violations (CLAUDE.md)

4. Delta comment in bench-sqlite.ts

Per CLAUDE.md: Documenting deltas is not important or useful. The comment describes what was removed rather than what is. Replace with a forward-looking comment explaining what the block does now, or remove it if the code is self-evident.


Data migration concern

5. Orphaned WASM SQLite KV data

SQLITE_PREFIX ([8]) is removed from keys.ts. Any actors whose data was written by the WASM VFS path will see an empty database after this deploys. The KV entries at that prefix will be unreachable. If any production actors used the WASM path, a migration or release note is needed before this lands.


Minor observations

  • notGlobal.unwrap_or(false) in lib.rs -- correct fix for the now-optional field.
  • Engine driver getNativeDatabaseProvider() -- drops the try-catch intentionally (fail-by-default), but this.#envoy must be non-null when called. Worth verifying the envoy is always initialized before db() can be invoked.
  • SqliteDatabase interface in config.ts -- clean abstraction; good separation from RawAccess.
  • Teardown loops in both isolate-runtime.ts and index.cts handle cleanup correctly (iterate, try/catch per entry, clear after).
  • Root package.json resolutions cleanup -- removing @rivetkit/sqlite and @rivetkit/sqlite-vfs is correct.

Summary

The simplification is large and well-motivated. Three things should be addressed before merging: the cache-entry leak on close error (#1), the bigint precision hazard (#2), and confirming there are no production actors relying on the WASM SQLite KV path (#5). The delta comment (#4) is a quick fix.

@github-actions
Copy link
Copy Markdown
Contributor

Preview packages published to npm

Install with:

npm install rivetkit@pr-4614

All packages published as 0.0.0-pr.4614.822b57f with tag pr-4614.

Engine binary is shipped via @rivetkit/engine-cli (platforms: linux-x64-musl, linux-arm64-musl, darwin-x64, darwin-arm64). rivetkit resolves it automatically at runtime.

Docker images:

docker pull rivetdev/engine:slim-822b57f
docker pull rivetdev/engine:full-822b57f
Individual packages
npm install rivetkit@pr-4614
npm install @rivetkit/react@pr-4614
npm install @rivetkit/rivetkit-native@pr-4614
npm install @rivetkit/workflow-engine@pr-4614

@NathanFlurry NathanFlurry force-pushed the pkg-pr-new-native-builds branch from 4bd0fb1 to ab9f56f Compare April 13, 2026 02:09
@NathanFlurry NathanFlurry force-pushed the chore/remove-wasm-sqlite-native-only branch from a145cda to 2e5abc9 Compare April 13, 2026 02:09
@NathanFlurry NathanFlurry changed the base branch from pkg-pr-new-native-builds to graphite-base/4614 April 13, 2026 02:13
@NathanFlurry NathanFlurry force-pushed the chore/remove-wasm-sqlite-native-only branch from 2e5abc9 to ac6753a Compare April 13, 2026 02:13
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4614 to main April 13, 2026 02:13
@NathanFlurry NathanFlurry force-pushed the chore/remove-wasm-sqlite-native-only branch from ac6753a to ebe2cff Compare April 13, 2026 03:17
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.

1 participant