Repository navigation
Take over stop signals before a page server announces its URL - #3461
Merged
Merged
Conversation
#3452 installed the `exit_serving` handlers after the URL was printed, so a Ctrl-C sent as soon as the URL appeared could still unwind and exit 1 with "interrupted". `test_server_run_persistent_declines_the_claim_a_harness_session_offers` hit that window on CI three times. The handlers now go in when the service commits, before the URL leaves the process on either path: `server run`'s announcement and `_serve`'s handshake confirmation. Follow-up to Max's decision #34 on the overnight report. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 21, 2026
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.
A page server now installs its
exit_servingsignal handlers as its service commits, before its URL leaves the process. Before this change it installed them only after the URL was printed. This is a follow-up to #3452 (Max's decision #34 on the overnight report).The bug. #3452 installed the handlers just before the server started its threads, which comes after
server runprints the URL. Ctrl-C sent as soon as the URL appeared could land in between. It then took the old unwinding path and exited 1 with{"error": "interrupted"}instead of 130.test_server_run_persistent_declines_the_claim_a_harness_session_offerssends SIGINT as soon as it reads the URL line, and it failed this way on CI in #3455, #3459 and #3460 (run). A user pressing Ctrl-C right after the URL appears hits the same window.The fix.
cmd_serve'scommit()installs the handlers once the service is committed and before it returns. Both paths that hand the URL out run aftercommit():server runprints it, and_servesends the handshake confirmation thatserver startprints. A signal during the commit still unwinds, so a failed commit still rolls the service back.Checked. A temporary test (not committed) started
leaf server run --persistent, read the URL line and signaled at once. With a 0.05 s sleep injected right after the URL is printed:SIGTERM's status doesn't show which path it took, since the unwinding path also exits 143. Without the injected sleep, 100 trials of each signal passed on both versions on a lightly loaded Mac; the failure needs CI's scheduling delay. The focused server lifetime, server process, title and preview handoff tests pass (193).