Skip to content

fix(rivetkit): prevent Turbopack from tracing sqlite-vfs dynamic import#4490

Draft
NathanFlurry wants to merge 1 commit into03-23-fix_rivetkit_warn_when_manager_port_falls_back_to_a_different_portfrom
03-23-fix_rivetkit_prevent_turbopack_from_tracing_sqlite-vfs_dynamic_import
Draft

fix(rivetkit): prevent Turbopack from tracing sqlite-vfs dynamic import#4490
NathanFlurry wants to merge 1 commit into03-23-fix_rivetkit_warn_when_manager_port_falls_back_to_a_different_portfrom
03-23-fix_rivetkit_prevent_turbopack_from_tracing_sqlite-vfs_dynamic_import

Conversation

@NathanFlurry
Copy link
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
Member Author

NathanFlurry commented Mar 24, 2026

@railway-app
Copy link

railway-app bot commented Mar 24, 2026

🚅 Deployed to the rivet-pr-4490 environment in rivet-frontend

Service Status Web Updated (UTC)
website 😴 Sleeping (View Logs) Web Mar 24, 2026 at 2:17 am
frontend-cloud 😴 Sleeping (View Logs) Web Mar 24, 2026 at 2:09 am
frontend-inspector 😴 Sleeping (View Logs) Web Mar 24, 2026 at 2:06 am
ladle ❌ Build Failed (View Logs) Web Mar 24, 2026 at 2:01 am
kitchen-sink ❌ Build Failed (View Logs) Web Mar 24, 2026 at 2:00 am
mcp-hub ✅ Success (View Logs) Web Mar 24, 2026 at 1:58 am

@claude
Copy link

claude bot commented Mar 24, 2026

PR Review: fix(rivetkit): prevent Turbopack from tracing sqlite-vfs dynamic import

This is a targeted fix for a Turbopack-specific bundler issue. The change is small and well-reasoned.

What the fix does

By constructing the module specifier as ["@rivetkit", "sqlite-vfs"].join("/") instead of a static string literal, the dynamic import becomes opaque to Turbopack's static analysis at compile time. This prevents Turbopack from eagerly tracing into @rivetkit/sqlite-vfs's transitive WASM dependencies, which it can't handle.

Positives

  • The comment clearly explains the "why" and the mechanism — important for a non-obvious workaround like this.
  • The fix is minimal and surgical — exactly the right scope.

Minor concern: inline type annotation length

The type annotation on line 31 is quite long and wraps awkwardly:

({ SqliteVfsPool }: { SqliteVfsPool: new (opts: { actorsPerInstance: number; idleDestroyMs: number }) => { acquire(actorId: string): Promise<ISqliteVfs>; shutdown(): Promise<void> } }) =>

Since the file already imports ISqliteVfs from @rivetkit/sqlite-vfs, consider extracting a local type alias for readability:

type SqliteVfsPoolCtor = new (opts: { actorsPerInstance: number; idleDestroyMs: number }) => {
    acquire(actorId: string): Promise<ISqliteVfs>;
    shutdown(): Promise<void>;
};

this.#poolPromise = import(specifier).then(
    ({ SqliteVfsPool }: { SqliteVfsPool: SqliteVfsPoolCtor }) =>
        new SqliteVfsPool({ actorsPerInstance: poolConfig.actorsPerInstance, idleDestroyMs: poolConfig.idleDestroyMs }),
);

This is a readability nit only — the current code is functionally correct.

Questions / considerations

  • Fragility of the workaround: Is there a Turbopack issue filed upstream? The Array.join() trick is clever but could theoretically be optimized through in a future Turbopack version. A comment linking to an upstream issue would help future maintainers know if/when this can be removed.
  • Other bundlers: This should be safe for webpack/esbuild since they generally don't statically analyze dynamic imports with computed specifiers, but worth verifying.

Summary

The fix is correct and well-commented. The only suggestion is a minor readability improvement on the inline type annotation. LGTM.

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