You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.