Skip to content

chore(rivetkit): remove wasm sqlite runtime#4614

Open
NathanFlurry wants to merge 1 commit into04-12-fix_sqlite-native_restore_native_startup_kv_preloadfrom
chore/remove-wasm-sqlite-native-only
Open

chore(rivetkit): remove wasm sqlite runtime#4614
NathanFlurry wants to merge 1 commit into04-12-fix_sqlite-native_restore_native_startup_kv_preloadfrom
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

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

@claude
Copy link
Copy Markdown

claude bot commented Apr 12, 2026

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

Overview

This PR removes the WASM SQLite runtime (@rivetkit/sqlite-wasm) and the deprecated NativeSqliteConfig / native-sqlite.ts transport-based approach in favor of a cleaner NativeDatabaseProvider abstraction that opens databases from a live runtime handle (the native envoy). It's a significant simplification: ~1,700 lines deleted, ~490 added, and several layers of indirection removed.


Positive Changes

  • Cleaner abstraction. Replacing ISqliteVfs + NativeSqliteConfig + openActorDatabase with a single NativeDatabaseProvider / SqliteDatabase interface is the right direction. Less surface area, easier to reason about.
  • Dead code removed. native-sqlite.ts, native-adapter.ts, open-database.ts, sqlite-pool.ts, and SqliteVfsPoolManager are cleanly deleted. The @rivetkit/sqlite-wasm dependency is also dropped from package.json.
  • Duplicate binding normalization eliminated. Both wrapper.js and native-adapter.ts had their own copies of normalizeBindings/toNativeBinding. The new native-database.ts consolidates this into one place.
  • Isolate bridge improved. DB operations are now explicit named bridge keys (dbExec, dbQuery, dbRun, dbClose) rather than going through the VFS pool. This is more debuggable and does not carry WASM lifecycle overhead.
  • Rust comment cleanup. Removing Matches <TypeScript file> cross-references from kv.rs and vfs.rs is correct since the WASM counterpart is gone; no stale pointers.

Issues and Suggestions

1. Silent swallowed errors during shutdown (high)

In dynamic-isolate-runtime/src/index.cts, the shutdown loop swallows all close() errors with // noop. The same pattern appears in isolate-runtime.ts. Per the project style (and how WebSocket session teardown is handled in those same files), errors should be logged at warn level instead of silently ignored, so they appear in diagnostics when actors fail to clean up cleanly.

2. Modifying Map while iterating it (medium)

In index.cts, the shutdown loop calls database.close(), which internally calls nativeDatabaseCache.delete(actorId) (via createNativeDatabaseBridge's close() implementation), and then the loop also calls nativeDatabaseCache.delete(actorId) again. The double-delete is benign but confusing. Mutating a Map during .entries() iteration is safe in JS but can be surprising. Consider snapshotting and clearing first:

const entries = [...nativeDatabaseCache.entries()];
nativeDatabaseCache.clear();
for (const [, database] of entries) { ... }

3. Removed user-facing error context for native database failures (medium)

The old db/mod.ts wrapped errors with a descriptive message when the underlying KV/VFS layer became unavailable:

"Database query failed because the underlying storage is no longer available (...)."

This hint is now gone. When the envoy disconnects mid-query, users will see a raw error from the native layer with no guidance to check c.abortSignal. Consider retaining this at the RawAccess.execute level.

4. toNativeBindings silently changes behavior for named-param objects without placeholders (low)

In the new native-database.ts, when a named-param object is passed but the SQL has no named placeholders, the function falls through to Object.values(params).map(...) rather than throwing. The old code in both native-adapter.ts and wrapper.js threw an explicit error in this case. This is a subtle behavior change that could mask binding mismatches.

5. NativeDatabaseProvider.open is a breaking interface change (low, informational)

The old signature accepted optional preloaded entries; the new one drops them entirely and also changes the return type from Promise<RawAccess> to Promise<SqliteDatabase>. Any external driver implementing this interface will need updating. Worth noting in the PR description.

6. CLAUDE.md VFS parity requirement is now stale (low)

CLAUDE.md still says "The native Rust VFS and the WASM TypeScript VFS must match 1:1" and lists sqlite-wasm/src/vfs.ts as a relevant file. Since that package is being removed, this section should be revised so it does not mislead future contributors.

7. Test checklist is unchecked (low)

Given the scale of this change (all db paths route through the native provider), a note on which driver tests cover the new path, and whether any fixtures that used createSqliteVfs were updated, would help reviewers gain confidence.


Summary

Well-scoped cleanup that removes a significant amount of legacy indirection. The core design is sound. The main actionable items are: log shutdown close-errors instead of swallowing them, snapshot the Map before iterating during shutdown, and restore user-facing context in native database error paths. CLAUDE.md should also be updated to remove the now-inapplicable WASM VFS parity requirement.

@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 3 times, most recently from 9da1113 to e792448 Compare April 13, 2026 07:11
@NathanFlurry NathanFlurry changed the base branch from main to graphite-base/4614 April 13, 2026 08:24
@NathanFlurry NathanFlurry force-pushed the chore/remove-wasm-sqlite-native-only branch from e792448 to c0e0e30 Compare April 13, 2026 08:25
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4614 to 04-12-fix_sqlite-native_restore_native_startup_kv_preload April 13, 2026 08:25
@NathanFlurry NathanFlurry force-pushed the 04-12-fix_sqlite-native_restore_native_startup_kv_preload branch from bd95874 to ebe7c80 Compare April 13, 2026 21:07
@NathanFlurry NathanFlurry force-pushed the chore/remove-wasm-sqlite-native-only branch from c0e0e30 to 7158470 Compare April 13, 2026 21:07
@NathanFlurry NathanFlurry marked this pull request as ready for review April 14, 2026 21:33
@NathanFlurry NathanFlurry force-pushed the chore/remove-wasm-sqlite-native-only branch from 7158470 to 9ce9006 Compare April 14, 2026 23:43
@NathanFlurry NathanFlurry force-pushed the 04-12-fix_sqlite-native_restore_native_startup_kv_preload branch from ebe7c80 to 10901e6 Compare April 14, 2026 23:43
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