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
Overall this is a clean, well-scoped change: rayId is threaded consistently through RivetError, the client fetch/WebSocket/retry paths, deconstructError, and the NAPI bridge round trip, with solid new unit test coverage (round-trip encode/decode, metadata isolation, HTTP header attachment, Rust bridge payload round trip). Style matches repo conventions (structured tracing fields, no _ => fallthrough issues, hard tabs in Rust, etc.).
Correctness gap: the actor's own HTTP router never emits rayId
common/router.ts::handleRouteError is the function that turns an in-actor error into the HTTP response sent back to a caller. It calls the newly-updated deconstructError(...), but only destructures { statusCode, group, code, message, metadata, actor } — rayId is dropped:
No x-rivet-ray-id header is set on the outgoing response, and HttpResponseErrorSchema has no rayId field either. Meanwhile the client-side code this PR adds (client/utils.ts, client/actor-handle.ts) explicitly reads x-rivet-ray-id from response headers to populate RivetError.rayId. So for a RivetError that originates inside an actor (e.g. an internal engine/KV/SQL call that failed and carried an engine ray ID, now preserved on the error per this PR), that ray ID is captured all the way through deconstructError, then silently discarded at the last step before it reaches the wire. This undercuts the PR's own stated goal of preserving ray IDs "through HTTP decoding ... scheduling errors ... reload failures" — it holds for gateway/engine-originated errors decoded on the client, but not for errors an actor raises and returns through its own router.
Related: the default sanitized-error branch also drops rayId
In common/utils.ts::deconstructError, the final else branch (hit whenever exposeInternalError is false and the error isn't public — the default in production, since RIVET_EXPOSE_ERRORS is unset unless explicitly enabled) builds a generic opaque INTERNAL_ERROR_DESCRIPTION response. It preserves actor when available, but never assigns rayId:
Since a ray ID is meant to be a safe, non-sensitive correlation handle (per the new doc comment: "used to correlate this error with engine logs"), this is exactly the branch where surfacing it would be most valuable — an opaque 500 with no other diagnostic info. Worth adding rayId = error.rayId alongside the actor assignment here (and then wiring it out through handleRouteError above) to fully close the loop this PR is opening.
Minor / non-blocking
The rivetkit-napi/src/actor_context.rsverify_inspector_auth_js change (ray_id: None) is correct as-is — that's a locally-generated 401, no upstream ray ID exists.
Test coverage for the client-header path and the Rust bridge round trip is solid; per the PR description, the NAPI Rust test and the driver matrix couldn't actually be run in the author's environment, so it'd be good to confirm CI runs cargo test -p rivetkit-napi and the driver suite before merge.
No security or performance concerns — this is purely metadata plumbing over already-established boundaries, and no unbounded/sensitive data is added to logs or metrics.
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.
Summary
x-rivet-ray-idas the top-levelRivetError.rayIdfield without changing application error metadataNo Trace ID support or engine response contract changes are included.
Testing
pnpm exec vitest run tests/rivet-error.test.tspnpm run check-typesinrivetkit-typescript/packages/rivetkitgit diff --checkEnvironment limitations
@rivetkit/engine-cli-linux-x64-muslis unavailable.