Skip to content

test: fix two Linux CI flakes: receive loop deadlines and a leaked sign-in continuation - #408

Merged
jeanmatthieu merged 2 commits into
rel/1.0.0from
fix/receive-loop-test-deadlines
Nov 30, 2026
Merged

jeanmatthieu merged 2 commits into
rel/1.0.0from
fix/receive-loop-test-deadlines

Conversation

@jeanmatthieu

@jeanmatthieu jeanmatthieu commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Motivation and Context

This fixes two test problems that show up in the Linux CI runs of
#407, which only changes
StdioTransport.

Receive loop tests time out on a loaded runner

Two tests in ClientReceiveLoopTerminationTests fail when a 2-second outcome(within:)
limit runs out:

  • "An in-memory peer disconnecting fails the request in flight"
  • "A request handler can reconnect, and answers on the connection it came from"

Neither has found a wrong result. When they fail, the unrelated tests around them take 3.3
to 5.0 seconds each, so the runner is overloaded and the cooperative pool does not run the
client's work in time. The reconnect test's later checks pass, which means the reconnect
did finish, just after the limit. #407 failed this way on Ubuntu 24.04, then twice more on
RHEL UBI 9 when the failed jobs were re-run. The reconnect test also failed the same way
on the iOS job of an unrelated branch (oss/network-heartbeat-framing).

Every wait in this suite for something that must finish now uses one limit,
completionLimit, set to 10 seconds. A passing test returns as soon as the operation
finishes, so the higher limit only adds time when a test fails. Each test still has the
suite's one-minute .timeLimit. The 200 ms check that a request does not fail early
("A replaced connection closing does not affect the current one") keeps its short limit,
and the 1-second cleanup wait is unchanged.

SWIFT TASK CONTINUATION MISUSE from the mock authorizer

The Linux logs print:

SWIFT TASK CONTINUATION MISUSE: handleChallenge(statusCode:headers:endpoint:operationKey:session:)
leaked its continuation without resuming it. This may cause tasks waiting on it to remain
suspended forever.

It comes from SlowSignInAuthorizer in ClientConnectionFailureTests. "Cancelling
connect during sign-in stops waiting promptly" holds the server/discover sign-in until
release(). Cancelling connect can also send notifications/cancelled for that
request. Its POST gets a 401 as well, which starts a second sign-in while the first one
waits. The mock kept one continuation, so the second sign-in replaced the first. The
dropped continuation was freed without being resumed, and the server/discover POST stayed
suspended for the rest of the run. Which of the two gets there first depends on
scheduling, which is why the warning shows up on loaded Linux runners and not on macOS.

The mock now keeps every waiting sign-in, and release() resumes them all. This changes
only test code.

How Has This Been Tested?

  • swift test passes on macOS, and so do ClientReceiveLoopTerminationTests and
    ClientConnectionFailureTests run on their own.
  • The overload could not be reproduced on macOS, so the evidence for the deadlines is the
    CI logs, where every test running alongside took more than the old limit.
  • The leak was reproduced in a 2-CPU RHEL UBI 9 container (scripts/ci-linux.sh --cpus 2).
    Before the change it showed up in 4 of 4 full test runs, each time with a second challenge
    for notifications/cancelled. After it, it showed up in none of 6 runs, and every run
    passed.

Breaking Changes

None. Only test code changes.

Types of changes

  • Test fix (non-breaking)

AI Assistance

Drafted with an AI coding agent (Claude), then reviewed by me.

Two tests in ClientReceiveLoopTerminationTests failed on the Ubuntu 24.04
job of #407, a change to StdioTransport only. The 2-second limit of
outcome(within:) ran out in both. Neither found a wrong result. The tests
that ran alongside took 4.4 to 5.0 seconds each, so the overloaded runner
did not get to the client's work within the limit. The reconnect test
also failed the same way on an unrelated branch's iOS job.

Every wait in the suite for something that must finish now uses one
10-second limit. A passing test returns as soon as the operation does, so
the limit only adds time when a test fails, and the suite's one-minute
time limit still applies. The 200 ms check that a request does not fail
early keeps its short limit.

Assisted-by: Claude
@jeanmatthieu
jeanmatthieu requested a review from a team as a code owner November 30, 2026 10:44
"Cancelling connect during sign-in stops waiting promptly" holds the
server/discover sign-in until release(). Cancelling connect can also
send notifications/cancelled for that request. Its POST gets a 401 as
well, which starts a second sign-in while the first one waits.
SlowSignInAuthorizer kept one continuation, so the second sign-in
replaced the first. The dropped continuation was freed without being
resumed, and the runtime printed SWIFT TASK CONTINUATION MISUSE. The
server/discover POST stayed suspended for the rest of the run.

The mock now keeps every waiting sign-in, and release() resumes them all.

The warning appears in the Linux CI logs. On a 2-CPU Linux container it
showed up in 4 of 4 full test runs, each with a second challenge for
notifications/cancelled. After the change it showed up in none of 6.

Assisted-by: Claude
@jeanmatthieu jeanmatthieu changed the title test: give the receive loop tests 10 seconds to finish a request test: fix two Linux CI flakes: receive loop deadlines and a leaked sign-in continuation Nov 30, 2026
@jeanmatthieu
jeanmatthieu merged commit a74d320 into rel/1.0.0 Nov 30, 2026
14 checks passed
@jeanmatthieu
jeanmatthieu deleted the fix/receive-loop-test-deadlines branch November 30, 2026 13:19
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