Repository navigation
test(daemon): rejoin after the daemon drops the closed connection's lease - #80
Merged
Merged
Conversation
…ease The reconnect-within-grace test reopened the unit as soon as the first client's socket closed, but the daemon handles that close later. When the second open won the race the old lease was still counted (leases 2), which failed main on 11-22 (run 45051468599) and a PR run the same day. The test now watches unit events on the second connection and reopens only after the daemon broadcasts the lease drop, the state the test describes. The harness's event wait now resolves when the event arrives instead of polling its buffer every 25 ms. Both changes sit in SA-DAEMON-REJOIN marker blocks in Oh My Pi's test files. Proven by delaying the daemon's close handling by 300 ms: the old test fails exactly as CI did (expected 1, received 2 at line 110), 3/3; the new test passes with and without the delay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yaacovcorcos
force-pushed
the
claude/ci-daemon-rejoin-20261123
branch
from
November 23, 2026 05:30
8e50dd2 to
5dc528c
Compare
…ness unchanged Codex review: a waiter implementation inside an upstream harness file is logic, not a small hook. The grace test above already waits for this exact lease drop with until() and describe(), so the rejoin test reuses it and the harness is back to Oh My Pi's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the flake that turned main red on 11-22 (run 45051468599) and failed a PR run the same day:
daemon unit lifecycle › a client reconnecting within the grace adopts the same processexpectedleases1, got 2.Cause. The test harness's
close()settles when the client socket closes, but the daemon drops that connection's lease later, when it handles the close (server.ts#onClose→units.disconnected). When the second client's open was handled first, the stale lease was still counted. The daemon's behaviour is correct (connection-bound lease accounting), so only the test changes.Fix (test only, new contract
SA-DAEMON-REJOIN). Before reopening, the test waits untildescribeshows the daemon has dropped the lease, the sameuntil()+describe()wait the grace test just above it already uses. The harness is unchanged (Codex review: an earlier version added an event waiter to the upstream harness file, which is logic rather than a small hook).Proof. With the daemon's close handling delayed by 300 ms, the old test fails exactly as CI did (expected 1, received 2); the new test passes 3/3 with the delay, and the whole lifecycle file passes 5/5 without it (10 tests each). Typecheck, oxlint and oxfmt are clean, and the divergence check passes locally.
Footprint. +1 marker block / +6 lines in 1 Oh My Pi test file. It's an inherited flake, so it needs an upstream fix.
Found in review, not changed here. Pre-existing in Oh My Pi's daemon (
units.tsopen()): if a client disconnects while its open is still creating the unit,disconnected()runs beforeopen()adds that client's lease, so the lease is never dropped and the unit stays pinned. Separate product fix, upstream first.Platforms: the test file is skipped on Windows; same behaviour on macOS and Linux.
🤖 Generated with Claude Code