Skip to content

fix(rivetkit): surface native runtime load failures instead of masking them with wasm - #5670

Open
MasterPtato wants to merge 1 commit into
stack/fix-envoy-client-fail-sent-vfs-sqlite-requests-on-disconnect-instead-of-stalling-until-expiry-snwrsykwfrom
stack/fix-rivetkit-surface-native-runtime-load-failures-instead-of-masking-them-with-wasm-mputlvxy
Open

fix(rivetkit): surface native runtime load failures instead of masking them with wasm#5670
MasterPtato wants to merge 1 commit into
stack/fix-envoy-client-fail-sent-vfs-sqlite-requests-on-disconnect-instead-of-stalling-until-expiry-snwrsykwfrom
stack/fix-rivetkit-surface-native-runtime-load-failures-instead-of-masking-them-with-wasm-mputlvxy

Conversation

@MasterPtato

@MasterPtato MasterPtato commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@MasterPtato

Copy link
Copy Markdown
Contributor Author

@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Code Review

Small, well-scoped fix. Reviewed rivetkit-typescript/packages/rivetkit/src/registry/native.ts and the new tests in runtime.test.ts.

Summary

Previously, loadAutoRuntime silently swallowed the native-runtime load error whenever the wasm fallback succeeded, and if wasm also failed, the caller only ever saw the wasm error (with zero context about why native failed). This PR:

  • Captures the native error and logs it via logger().warn(...) before falling back to wasm, so a silently-skipped platform binding is no longer invisible when wasm happens to succeed.
  • When both native and wasm fail, throws a single RivetError("config", "runtime_unavailable", ...) that includes both underlying error messages instead of only the (usually irrelevant) wasm file:// fetch error.

Correctness

Control flow is correct: nativeError is unconditionally assigned in the first catch before the second try block can run, so there is no uninitialized-use path. The edge-like host short-circuit is untouched, and the explicit native/wasm request paths in loadConfiguredRuntime are unaffected, this change only touches the auto fallback path. No bugs found.

Style / conventions

  • Structured logging (logger().warn({ msg, error: stringifyError(error) })) matches the existing pattern used elsewhere in this file.
  • Comments are written as complete sentences per CLAUDE.md conventions.
  • The new RivetError group/code (config/runtime_unavailable) is consistent with neighboring TS-only errors in the same file (unknown_runtime, wasm_local_sqlite). Since this is a TS-native RivetError, not a Rust #[derive(RivetError)] type, no generated-artifact update is needed.

Test coverage

Good coverage in runtime.test.ts via an injectable RuntimeLoaders: native success, native failure with wasm fallback, both failing (asserts both error messages are present in the thrown error), and the edge-host path never touching native. These are solid, deterministic unit tests with no mocking of real infra, consistent with the repo testing conventions.

Minor nits (non-blocking)

  • The combined error message concatenates the two error strings with only a space separating "Native runtime: ..." and "Wasm runtime: ...". If stringifyError includes a stack trace (gated by the getLogErrorStack() debug flag), the boundary between the two sections becomes harder to read. A newline or semicolon separator would improve readability.
  • This new error is constructed with public: true, so stringifyError output, including a stack trace when the debug flag is enabled, can propagate to the client. This mirrors existing sibling errors in the file, so it is likely intentional, but worth double-checking that this is the desired exposure for this code path.

Nothing blocking, looks safe to merge.

@MasterPtato
MasterPtato force-pushed the stack/fix-rivetkit-surface-native-runtime-load-failures-instead-of-masking-them-with-wasm-mputlvxy branch from 977f970 to 525a1d5 Compare September 4, 2026 23:07
@MasterPtato
MasterPtato force-pushed the stack/fix-envoy-client-fail-sent-vfs-sqlite-requests-on-disconnect-instead-of-stalling-until-expiry-snwrsykw branch from e8ddfc9 to 3adb1e9 Compare September 4, 2026 23:07
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