Skip to content

fix(rivetkit-native): expose full hibernation metadata to JS#4657

Open
NathanFlurry wants to merge 1 commit into04-15-chore_rivetkit_remove_inline_testsfrom
break-up/expose-hibernation-metadata
Open

fix(rivetkit-native): expose full hibernation metadata to JS#4657
NathanFlurry wants to merge 1 commit into04-15-chore_rivetkit_remove_inline_testsfrom
break-up/expose-hibernation-metadata

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 14, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 14, 2026

PR Review: fix(rivetkit-native): expose full hibernation metadata to JS

Summary

This PR adds four fields to the HibernatingRequestEntry interface in rivetkit-typescript/packages/rivetkit-native/index.d.ts: envoyMessageIndex, rivetMessageIndex, path, and headers?. The change brings the TypeScript declaration in sync with the underlying Rust struct HibernatingWebSocketMetadata in engine/sdks/rust/envoy-client/src/tunnel.rs.

Code Quality and Correctness

The fix is correct and necessary. Without these fields, restoreHibernatingRequests was called with an incomplete HibernatingRequestEntry shape. The Rust consumer reads meta.envoy_message_index, meta.rivet_message_index, meta.path, and meta.headers to reconstruct WebSocket state. Without the correct message indices, hibernation restore would silently initialize both to 0 instead of their true persisted values, breaking at-most-once message deduplication on wake.

The field mapping is consistent. The callers in actor-driver.ts correctly map entry.serverMessageIndex to rivetMessageIndex and entry.clientMessageIndex to envoyMessageIndex, matching the Rust field semantics.

Potential Issues

  • headers is typed as optional (headers?) but the Rust struct declares it non-optional (HashMap<String, String>). The field is always present on the Rust side. Marking it optional means callers could pass undefined. Recommendation: Change headers? to headers (non-optional) to match the Rust type.

Auto-generated File Warning

The file header reads /* auto-generated by NAPI-RS */ but HibernatingWebSocketMetadata in engine/sdks/rust/envoy-client/src/tunnel.rs has no #[napi] attribute. The file appears to be manually maintained. The header comment should be amended to avoid misleading future contributors.

Test Coverage

No tests added. A driver-level integration test exercising hibernation and wake (hardCrashActor) would catch regressions of this class in the future.

Verdict

  1. Make headers non-optional to match Rust type.
  2. Clarify the auto-generated header comment.
  3. No blocking issues. The core fix is correct and required for proper hibernation restore semantics.

Reviewed by Claude Sonnet 4.6

@NathanFlurry NathanFlurry force-pushed the break-up/expose-hibernation-metadata branch from 26f98bc to fde1e0b Compare April 15, 2026 02:40
@NathanFlurry NathanFlurry force-pushed the break-up/persist-hibernating-requests branch from 88f4613 to ae4fe54 Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry force-pushed the break-up/expose-hibernation-metadata branch from fde1e0b to 789b9cd Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry force-pushed the break-up/persist-hibernating-requests branch from ae4fe54 to c862fec Compare April 15, 2026 06:55
@NathanFlurry NathanFlurry force-pushed the break-up/expose-hibernation-metadata branch from 789b9cd to 38e331e Compare April 15, 2026 06:55
@NathanFlurry NathanFlurry changed the base branch from break-up/persist-hibernating-requests to graphite-base/4657 April 27, 2026 05:57
@NathanFlurry NathanFlurry force-pushed the break-up/expose-hibernation-metadata branch from 38e331e to cf8854f Compare April 27, 2026 05:57
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4657 to 04-15-chore_rivetkit_remove_inline_tests April 27, 2026 05:58
@NathanFlurry NathanFlurry marked this pull request as ready for review April 27, 2026 06:38
@NathanFlurry NathanFlurry force-pushed the break-up/expose-hibernation-metadata branch from cf8854f to 002a248 Compare April 27, 2026 07:08
@NathanFlurry NathanFlurry force-pushed the 04-15-chore_rivetkit_remove_inline_tests branch from 22e1c37 to 120eb41 Compare April 27, 2026 07:08
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