Repository navigation
fix(tlon): stop SSE reconnects after client close - #108168
Conversation
546088a to
7c58bc4
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 12:37 PM ET / 16:37 UTC. ClawSweeper reviewWhat this changesThe PR makes Tlon’s Urbit SSE client abort pending ordinary and max-attempt reconnect delays when monitoring stops, with loopback-server and timer regression tests. Merge readinessThis remains a useful, narrowly scoped Tlon shutdown fix. The final branch cancels both delayed reconnect paths at the monitor-owned stop boundary, preserves normal active-client reconnects, and has real loopback SSE proof plus focused regression coverage; no discrete correctness or security defect is evident from the supplied final-head diff and review context. Priority: P2 Review scores
Verification
How this fits togetherTlon’s channel monitor owns an Urbit SSE client that authenticates, opens an event stream, and schedules reconnects when the stream ends. Monitor shutdown stops ingress and the client, so delayed reconnect work must observe that shutdown before it can re-authenticate or open another stream. flowchart LR
A[Tlon channel monitor] --> B[Urbit SSE client]
B --> C[SSE stream ends]
C --> D[Reconnect scheduler]
D --> E[Reconnect delay]
A --> F[Monitoring stops]
F --> G[Abort pending delay]
G --> H[No post-stop reconnect]
E --> I[Reconnect while monitor stays active]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +13, Tests +277. Total +290 across 3 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the focused abort-aware reconnect-delay change after exact-head CI/mergeability refresh, retaining the production-path regression tests that prove stop behavior and uninterrupted active reconnect behavior. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible with high confidence: the supplied loopback test drives the production SSE disconnect and delayed-reconnect path, calls the public shutdown path during the delay, and observes whether reconnect callbacks or requests occur afterward. The contributor reports that this failed before the fix and passes on the repaired path. Is this the best way to solve the issue? Yes: aborting the client-owned pending waits at the monitor shutdown boundary is narrower and safer than changing retry timing or adding a separate shutdown flag. It covers both retry delays while retaining the normal reconnect path for an active monitor. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4229e96e0ec3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Preserve the original Tlon SSE reconnect fix while canceling both retry timers at stopReceiving(), the real monitor shutdown boundary. Verified against an authenticated, SSRF-guarded loopback SSE server; both reconnect waits settle immediately without changing replay, close cleanup, or uninterrupted reconnection. Co-authored-by: wahaha1223 <[email protected]>
Prepare a conflict-free refresh of the original Tlon SSE shutdown correction without changing its ownership or losing the contributor commit. Co-authored-by: wahaha1223 <[email protected]>
Cancel both Tlon SSE reconnect waits at stopReceiving(), the monitor-owned shutdown boundary, while preserving guarded HTTP, durable same-channel replay, and the original contributor's fix. Verified with authenticated loopback SSE, both real retry delays, normal reconnection, all 252 Tlon tests, extension type checks, lint, and focused owner regressions. Co-authored-by: wahaha1223 <[email protected]>
|
Merged via squash.
|
* fix(tlon): stop reconnecting after SSE client close * fix(tlon): cancel SSE reconnect timers when monitoring stops Preserve the original Tlon SSE reconnect fix while canceling both retry timers at stopReceiving(), the real monitor shutdown boundary. Verified against an authenticated, SSRF-guarded loopback SSE server; both reconnect waits settle immediately without changing replay, close cleanup, or uninterrupted reconnection. Co-authored-by: wahaha1223 <[email protected]> * fix(tlon): prepare conflict-free reconnect refresh Prepare a conflict-free refresh of the original Tlon SSE shutdown correction without changing its ownership or losing the contributor commit. Co-authored-by: wahaha1223 <[email protected]> * fix(tlon): cancel reconnect timers when monitoring stops Cancel both Tlon SSE reconnect waits at stopReceiving(), the monitor-owned shutdown boundary, while preserving guarded HTTP, durable same-channel replay, and the original contributor's fix. Verified with authenticated loopback SSE, both real retry delays, normal reconnection, all 252 Tlon tests, extension type checks, lint, and focused owner regressions. Co-authored-by: wahaha1223 <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where operators stopping a Tlon channel monitor during an SSE reconnect delay could still see the closed client re-authenticate and reconnect after the delay expired. The pending retry could outlive shutdown for up to 30 seconds, or 10 seconds in the max-attempt reset path.
Why This Change Was Made
Both reconnect waits now share a client-owned abort controller that terminal
close()cancels before channel cleanup. The change is limited to the Tlon SSE client's reconnect lifecycle; it does not change connection setup, retry timing, configuration, or the separateopenStreamtimeout path.User Impact
Stopping a Tlon monitor now cancels pending SSE reconnect work immediately, so a closed client no longer invokes re-authentication callbacks or opens another channel after shutdown. Reconnects still occur normally when the client remains open.
Evidence
AI-assisted.
Real production-path proof was run on the contributor machine with Node 24.18.0. The regression test starts a real loopback HTTP server and drives the production
UrbitSSEClientthrough SSRF validation, channel create/wake requests, an SSE GET that ends, the production reconnect scheduler, and publicclose()cleanup.Before the fix, on latest main at
fc56b554, this exact command reproduced the terminal reconnect:The failed assertion records one real
onReconnectcallback afterclose(). The second test was the negative control and passed, confirming that an uninterrupted 100 ms backoff still reconnects normally.Premise checks:
1000msreconnect delay beforeclose()ran.packages/retry/src/index.tsconfirmssleepWithAbortclears its timer and abort listener when its signal aborts.close()cancels it beforeonReconnector the normal retry delay can run.After the fix, rebased onto
63aafd003, the same real-server path plus the extended-backoff regression and the existing SSE client suite passed:Additional validation:
Targeted lint and diff checks passed. Autoreview reported no accepted/actionable findings and judged the patch correct with 0.96 confidence.
Not tested: a credentialed remote Tlon ship. The exercised network, SSE, retry, and shutdown code is production code; the local server substitutes only the remote Urbit endpoint.