fix(rivetkit-native): expose full hibernation metadata to JS#4657
fix(rivetkit-native): expose full hibernation metadata to JS#4657NathanFlurry wants to merge 1 commit intobreak-up/persist-hibernating-requestsfrom
Conversation
PR ReviewThis PR fixes two genuine correctness bugs in the native envoy hibernation path.
Both are real bugs and the general approach is correct. Medium: ThreadsafeFunctionCallMode::Blocking should be NonBlocking in can_hibernate. Using Blocking mode can deadlock if the JS thread is already processing another TSFN call. Every other event_cb.call() in the file uses NonBlocking, and NonBlocking is sufficient since the response arrives via rx.blocking_recv(). Low: Response map entry is leaked on error in can_hibernate. If rx.blocking_recv() returns Err, the entry for response_id is never removed from response_map. The async paths clean up correctly but the synchronous path does not. Low: The dual canHibernate call pattern is undocumented. wrapper.js calls canHibernate in two distinct places. A comment explaining when each is called would help maintainers. Nit: r.headers.unwrap_or_else(HashMap::new) is more idiomatic as r.headers.unwrap_or_default(). Positive: Switching ResponseMap to std::sync::Mutex is correct given that can_hibernate is a synchronous fn using block_in_place. Keeping WsSenderMap as tokio::sync::Mutex is also correct. No tests added. The can_hibernate round-trip and hibernation restore with real metadata are non-trivial. An integration test covering the hibernation/wake-up cycle through the native bridge would help prevent regressions. |
26f98bc to
fde1e0b
Compare
88f4613 to
ae4fe54
Compare
fde1e0b to
789b9cd
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: