Skip to content

Close half-open companion connections on shutdown - #158

Merged
BunsDev merged 6 commits into
mainfrom
companion-close-handshake
Oct 11, 2026
Merged

BunsDev merged 6 commits into
mainfrom
companion-close-handshake

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

iPhone companion failed on main at #154 (run 37983100896) after the readiness fixes in #153 had landed. The paired flow's /resume call to the Mac fixture timed out:

  • The runner was healthy. Its Session log shows the test's 10 s wait expiring on schedule, so the simulator was not the bottleneck this time.
  • The fixture answers /resume only after CompanionServer.dispose() returns, and https.Server.close() was waiting on a socket the phone had opened but never carried through the TLS handshake. closeAllConnections() only knows sockets that completed TLS, so Node held the server open until its 120 s handshake timeout.
  • A slow simulator stretched the outage step to 66 s in the failed run (10 s in the green runs around it), so the resume landed inside that window.

What

  • CompanionServer tracks every accepted socket per server and destroys them all in close(). Turning the companion off, quitting the Mac app, or rebinding after a network change no longer waits on a half-open connection.
  • Unit test: a half-open connection must not delay dispose(). It timed out at 5 s before the fix.
  • docs/status.md: unreleased entry and cause (4) in the iPhone CI rough edge.

Verification

  • Current signed head 8935eaf reconciles Stabilize macOS layout and Knowledge E2E readiness #167 without changing the reviewed fix's tree. npm run build && npm test passed: 469 passed, 1 skipped. The half-open connection regression passed in 142 ms; independent integration review confirmed the original source/test and retained status entries.
  • The current-head PR macOS workflow passed all 166 desktop and 7 site cases. Both current-head iPhone jobs passed.
  • The push macOS job passed build/unit checks and 165 desktop cases, but timed out on the initial empty-app app.close() in release.spec.ts, before the CLI-stop fixture started. Its cause remains unresolved. Twelve immediate-close probes, four native-quit controls, and three runs of the exact original test passed locally. The single diagnostic hosted rerun with debug logging passed. All four current-head checks are green; the original timeout remains unreproduced and its cause unresolved.
  • The original real fixture.mjs regression with a half-open connection changed /resume from no reply within 15 s before the fix to HTTP 204 in 6 ms afterward.

@vercel

vercel Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 11, 2026 7:42am UTC

Request Review

CompanionServer.close() destroyed only the sockets Node's
closeAllConnections() knows about, which are the ones that finished the
TLS handshake. A phone that opened a TCP connection but never sent its
ClientHello kept close() waiting for Node's 120 s handshake timeout. The
paused-Mac step of the iPhone CI flow answers /resume only after
dispose() returns, so on a slow simulator the UI test's 10 s wait expired
first (run 37983100896, main at #154). The runner's Session log showed its
wait ending on schedule, which placed the stall in the fixture.

Track every accepted socket per server and destroy them all in close().
A unit test holds a half-open connection and requires dispose() to return
promptly; it timed out at 5 s before the fix. Reproduced against the real
fixture with one half-open connection: no reply in 15 s before, 204 in
6 ms after.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The commit's pull_request run passed the whole paired iPhone flow while
its push run (38012518622) failed at the first follow-up, before the
pause-and-resume step this change affects. The phone's log shows one
request hitting its 8 s timeout ten seconds before the send tap and no
later request failing. The fixture writes no log, so the status page now
says what is known and what to add first if it recurs.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Main fa4e665 has the exact tree of verified ancestor e75fed0. The new merge retains the complete previously verified PR tree 6b50c08. Fresh hosted checks remain required.
@BunsDev
BunsDev merged commit c32f179 into main Oct 11, 2026
6 of 7 checks passed
@BunsDev
BunsDev deleted the companion-close-handshake branch October 13, 2026 12:48

This branch was successfully deployed

1 active deployment
Preview — 8935eaf4 Deployed Oct 11, 2026 by vercel[bot]
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.

1 participant