Skip to content

Take over stop signals before a page server announces its URL - #3461

Merged
max-sixty merged 1 commit into
mainfrom
agent-a9b4fc3990e8e8fa4
Oct 21, 2026
Merged

max-sixty merged 1 commit into
mainfrom
agent-a9b4fc3990e8e8fa4

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A page server now installs its exit_serving signal 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 run prints 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_offers sends 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's commit() installs the handlers once the service is committed and before it returns. Both paths that hand the URL out run after commit(): server run prints it, and _serve sends the handshake confirmation that server start prints. 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:

Version SIGINT trials Exited 130 SIGTERM trials Exited 143
main 100 0 (all exited 1, "interrupted") 100 100
this change 100 100 100 100

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).

This was written by Claude Code on behalf of max-sixty

#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]>
@max-sixty
max-sixty merged commit 1290dc3 into main Oct 21, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-a9b4fc3990e8e8fa4 branch October 21, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants