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 PR is a well-scoped cleanup that removes the WASM/KV-backed SQLite path from RivetKit, making native SQLite via @rivetkit/rivetkit-native the only supported backend. The architecture simplification is significant: ~11,000 lines deleted, removing the WASM pool manager, KV-backed VFS, native-sqlite.ts KV channel module, and native-adapter.ts.


Potential Bug: bigint precision loss in native-database.ts

In toNativeBinding, Number(arg) silently loses precision for bigint values outside Number.MAX_SAFE_INTEGER (2^53 - 1). SQLite stores integers up to i64, so this is reachable in practice. Consider throwing if the value exceeds safe integer range, or threading it as bigint through the native binding layer.


Orphaned KV Data (data integrity concern)

SQLITE_PREFIX (key byte 0x08) is removed from keys.ts and the preload configuration. Any existing actor that used the KV-backed WASM SQLite path will have data silently orphaned under that prefix with no cleanup, migration, or warning. If this replaces a version that served actors with KV-backed SQLite state, those actors would start with an empty database. Confirm whether a migration or hard cutover is intentional and document it in the PR description.


Removed error poisoning - verify native layer covers it

The old KV-backed path had a kvStore.poison() mechanism: before acquiring the mutex on close(), the KV store was poisoned so any in-flight query would immediately fail with a descriptive error rather than hanging. With native SQLite this depends entirely on the native layer. Confirm that the native backend propagates a clear error (not a hang) when the database is closed mid-query.


Removed tests without replacement coverage

Removed test suites:

  • actor-db-kv-stats.ts: appropriate, KV metrics path is gone
  • cross-backend-vfs.ts: appropriate, WASM is gone

However, the PR adds no new integration tests for the native-only path. The existing actor-db-raw, actor-db-stress, and actor-sleep-db tests presumably cover this, but it is worth confirming they pass with the native provider wired up end-to-end.


pnpm-lock.yaml deletion in examples/sandbox

Deleting a lockfile means the next pnpm install will resolve fresh versions, potentially diverging from what was tested. Consider regenerating rather than deleting.


openDatabaseFromEnvoy is now a static import

The old engine driver used a runtime require() with try/catch to optionally load native support and return undefined if unavailable. The new code imports openDatabaseFromEnvoy statically at the module level. getNativeDatabaseProvider() no longer has a fallback. Deployments without @rivetkit/rivetkit-native will now fail at import time rather than at runtime. Confirm this is the desired behavior and that the package is always present in deployment environments.


Overall Assessment

The goal of eliminating the WASM/KV-backed SQLite complexity is sound. The new SqliteDatabase interface in config.ts and wrapJsNativeDatabase in native-database.ts are cleaner than the previous multi-layer fallback chain. The dynamic actor DB bridge is well-structured and consistent with the existing KV bridge pattern.

Key items to address before merging:

  1. bigint precision in native-database.ts:toNativeBinding - silent data corruption risk for integers > 2^53
  2. Orphaned KV data - confirm intentional and document the cutover policy (existing actors with KV-backed SQLite state will lose it)
  3. Static import of openDatabaseFromEnvoy - confirm the deployment invariant that the native package is always available

@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 2 times, most recently from ebe2cff to 9da1113 Compare April 13, 2026 03:54
@NathanFlurry NathanFlurry force-pushed the chore/remove-wasm-sqlite-native-only branch from 9da1113 to e792448 Compare April 13, 2026 07:11
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