fix(runner): log warning instead of closing ws on message index gap#4594
fix(runner): log warning instead of closing ws on message index gap#4594NathanFlurry wants to merge 3 commits intov2.1.xfrom
Conversation
|
PR Review: fix(runner): log warning instead of closing ws on message index gap The core logic of each change is sound. Here is a breakdown by file. websocket-tunnel-adapter.ts - Gap handling relaxation The change to warn-and-continue instead of closing with 1008 is appropriate for hibernation semantics. During migration, messages may have been delivered with indices that appear as gaps to the new runner. Closing on any gap was too aggressive. One thing worth noting: the private field serverMessageIndex is still updated to the gapped value, so any late-arriving messages in the skipped range will be dropped by the de-dup check (wrappingLteU16). This is correct for at-least-once delivery semantics, but worth documenting with a comment. tunnel.ts - Hibernatable ws.downstream_closed bypass The new branch correctly performs the same in-memory cleanup (deleteWebSocket, deletePendingRequest, removeRequestToActor) while intentionally skipping adapter._handleClose() to preserve KV state for the next runner. The logic is sound. Minor concern: "ws.downstream_closed" is matched as a plain string literal but its canonical definition lives in Rust (engine/packages/pegboard-gateway/src/lib.rs). A comment pointing to the source would prevent silent drift if the string ever changes on the Rust side. state-manager.ts - saveState bug fix This is a genuine correctness fix. The early-exit guard in saveState() was inconsistent with the inner savePersistInner() check. The outer guard only checked the persistChanged flag, missing the connsWithPersistChanged.size > 0 condition. This meant connection state changes could be silently dropped when actor state itself had not changed. Suggestion: this fix has real impact on persistence correctness and would benefit from a unit test. A case where connsWithPersistChanged is non-empty but persistChanged is false, confirming that saveState now triggers a write, would be a good regression test. mod.ts - Diagnostic logging The new info-level logs and performance.now() timing around onActorStart are useful for debugging migration issues. Two things to consider:
Summary Severity / File / Issue:
Overall the changes are correct and the saveState fix closes a real persistence gap. The approach for handling message index gaps during hibernation is sound. |
651b567 to
065a506
Compare
c67fe26 to
0c8ba4a
Compare
Summary
Test plan
🤖 Generated with Claude Code