Skip to content

test(zero-swift): wait out a connect attempt a stalled system service holds up - #128

Merged
tmm merged 1 commit into
mainfrom
swift-wait-out-stalled-connect
Nov 10, 2026
Merged

tmm merged 1 commit into
mainfrom
swift-wait-out-stalled-connect

Conversation

@tmm

@tmm tmm commented Nov 10, 2026

Copy link
Copy Markdown
Member

Fixes two iOS Simulator flakes:

  • TransportProbeTests.clientReconnectsAfterTheServerGoesAwayMidFrame (urlSession, text), PR #122 run, and before that on Nov 6
  • AppLifecycleTests.hiddenDisconnectsAndShownReconnects, PR #124 run, and before that on Nov 6

Cause. In both, a URLSession connect attempt never reached the in-process test server. The probe's server saw no second upgrade request. The lifecycle server logged listener ready and never accepted. The client handled it as designed: the 10 s connect timeout ends the attempt, and the client retries 250–500 ms later, as zero-client does. Both tests gave up at that same moment:

  • The lifecycle test waits 10 s, which equals the connect timeout.
  • The probe waits 15 s. But URLSession only notices a frame cut by the server's FIN when the client next writes, and that's its ping 5 s in (pingTimeoutMs), so the reconnect starts at about 5.0 s (ts=5104 and ts=5042 in the CI logs) and gets under 10 s.

Freezing the simulator's configd_sim (SIGSTOP) reproduces both CI logs line for line while the test process keeps running. The lifecycle test's stop detector stays silent, as it did in CI. Both flakes predate the fast-reconnect port (#121), and neither goes through its backoff.

Change.

  • Waits for a connection now cover one timed-out attempt plus the first retry: connect timeout + the retry's longest wait + 2 s, plus pingTimeoutMs in the probe. The windows come from the client's constants.
  • The probe's failure output now includes the server's TCP accept count.
  • Only the waits for a connection change.

Verification (iOS 26.2 simulator, Xcode 26.3):

Scenario Before After
configd_sim frozen 16 s from the probe's first connection fails: server saw only connection 1, tcpAccepted 1 passes: the client's retry connects
configd_sim frozen 11.5 s from the lifecycle test's start fails, same lines as CI passes in 11.6 s
Full AppLifecycleTests and TransportProbeTests, no freeze — pass on the iOS simulator and on macOS
Probe under CPU load, 40 iterations 160/160 reconnects, every URLSession reconnect at about 5 s —

Test-only, so no changeset.

… holds up

TransportProbeTests.clientReconnectsAfterTheServerGoesAwayMidFrame and
AppLifecycleTests.hiddenDisconnectsAndShownReconnects flaked on the iOS
Simulator: a URLSession connect attempt never reached the in-process
server, and the test gave up as the client's connect timeout (10 s) ended
it, before the client's own retry, 250–500 ms later. Freezing the
simulator's configd_sim reproduces both failures line for line, with the
process running: the server sees no connection, the client logs
"Connecting to …" and then the timeout.

The lifecycle test waited 10 s for a connection. The probe waited 15 s,
but URLSession only sees a frame cut by the server's FIN when the client
next writes, its ping 5 s in, so the reconnect had under 10 s. Waits for a
connection now cover one timed-out attempt and the first retry: the connect
timeout, the retry's longest wait, and 2 s, plus the ping interval in the
probe. Under the same freezes both tests failed before and pass now, and the
client connects on its own retry.

The probe's failure output now says how many TCP connections the server
accepted, which tells a reconnect that never reached the server from one
whose request didn't arrive.

Amp-Thread-ID: https://ampcode.com/threads/T-0d2ed206-a5dd-4f42-9b68-c56e6b23e8f6
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm merged commit a99cd95 into main Nov 10, 2026
15 checks passed
@tmm
tmm deleted the swift-wait-out-stalled-connect branch November 10, 2026 22: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