Repository navigation
test: harden Waiter timeouts and reentrancy scheduling to fix flaky iOS CI - #6
Merged
Merged
Conversation
…s short. The 1-second deadline read CI simulator scheduler backlog as a product failure: on iOS runners keyedComputedRead() and serviceReadsTheDictionary() timed out while the same code passed on macOS. A successful wait resumes the moment the last resume() lands, so the deadline only bounds how long a genuinely broken run takes to fail; 10 seconds keeps every assertion intact. Tests that assert a serve must NOT arrive always wait out the full deadline, so they pass an explicit short timeout instead. Co-authored-by: Cursor <[email protected]>
…held. An async-let child is nonisolated and hops to the MainActor at an arbitrary later point, so releasing the gate right away raced: the first Execution could finish before the duplicate reached the Join, and the duplicate then legitimately started its own Execution and held the gate forever, hanging the suite. A MainActor Task enqueues its first slice immediately and the Join runs synchronously inside it, so yielding the actor before the release makes the Join certain. Reproduced hanging one run in four when looped; ten looped runs pass with the fix. Co-authored-by: Cursor <[email protected]>
MaximBazarov
added a commit
that referenced
this pull request
Sep 14, 2026
…OS CI (#6) * Give Waiter a generous default deadline, and keep must-not-serve waits short. The 1-second deadline read CI simulator scheduler backlog as a product failure: on iOS runners keyedComputedRead() and serviceReadsTheDictionary() timed out while the same code passed on macOS. A successful wait resumes the moment the last resume() lands, so the deadline only bounds how long a genuinely broken run takes to fail; 10 seconds keeps every assertion intact. Tests that assert a serve must NOT arrive always wait out the full deadline, so they pass an explicit short timeout instead. * Guarantee the firstWins duplicate joins while the first Execution is held. An async-let child is nonisolated and hops to the MainActor at an arbitrary later point, so releasing the gate right away raced: the first Execution could finish before the duplicate reached the Join, and the duplicate then legitimately started its own Execution and held the gate forever, hanging the suite. A MainActor Task enqueues its first slice immediately and the Join runs synchronously inside it, so yielding the actor before the release makes the Join certain. Reproduced hanging one run in four when looped; ten looped runs pass with the fix.
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.
Intent
Fix the failing StateManagement iOS CI tests. On PR #4, Test (iOS) failed with Timeout() in ComputedTests.keyedComputedRead() and DictionaryReadEntryPointTests.serviceReadsTheDictionary() (also named "A Service reads the whole dictionary, does not kick, and serves again on an entry write"). macOS Test passed on the same runs. That PR only changes docs/CI scripts/snippets, so treat this as an iOS reliability/correctness problem that is blocking green CI, not as a README change.
What Changed
Tests/Utils/Waiter.swiftnow takes a configurabletimeoutparameter with a generous 10-second default (up from a hardcoded 1 second), so scheduler backlog on parallel CI simulator runs is no longer misread as a test failure.ComputedTestsandRemoveValueTests(which always wait out the full deadline because a serve must not arrive) pass an explicit short 1-second timeout to keep runtime bounded.ReentrancyFirstWinsTestsreplaces the racyasync letduplicate operation with a@MainActorTaskplus yields, guaranteeing the duplicate joins the live first execution instead of occasionally starting its own and deadlocking on the gate.Risk Assessment
✅ Low: Test-only change that directly addresses the diagnosed iOS CI timeout cause at the shared Waiter boundary, preserves short deadlines for absence tests, fixes a source-verified test hang race, and touches no product code.
Testing
Reproduced the failing Test (iOS) CI job live by running its exact xcodebuild command against a local iPhone 17 simulator (Xcode 26.6): the full test target passed (267 tests), including both previously-failing tests. Stressed the two named flaky tests for 10 iterations and the restructured firstWins reentrancy test for 25 iterations on the iOS simulator with -run-tests-until-failure, all clean, and confirmed the shortened 1-second must-not-serve deadlines still trip Timeout correctly (those tests complete at ~1.22s only because Timeout throws). A targeted macOS swift test run of the affected suites also passed, showing the shared Waiter change does not regress the macOS job. The only thing not driven was reproducing the original failure at the base commit, since the flake is CI-load dependent and does not trigger deterministically on this fast local machine.
Evidence: Full iOS CI command run (xcodebuild test, iPhone 17 simulator) — TEST SUCCEEDED
~/.no-mistakes/evidence/01M2FK885BXWRZFCJ0XNXWBQ7N/ios-stress-computed-dictionary.log)~/.no-mistakes/evidence/01M2FK885BXWRZFCJ0XNXWBQ7N/ios-stress-25-iterations.log)~/.no-mistakes/evidence/01M2FK885BXWRZFCJ0XNXWBQ7N/macos-targeted-suites.log)Evidence: Previously-failing tests passing on iOS simulator
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
Tests/Operations/ReentrancyPolicyTests.swift:90- The firstWinsJoinsLiveExecution rework fixes a test not among the two failures named in the intent. The race is real and source-verified: the oldasync letduplicate is nonisolated and can reach the firstWins join after the first Execution finished, so it starts its own Execution and blocks forever on a gate that was already released, hanging the CI job. This fits the intent's broader framing of an iOS CI reliability problem blocking green CI, so it is noted for transparency rather than flagged as scope creep.Tests/Utils/Waiter.swift:33- The three must-NOT-serve tests keep a 1s deadline, so on the same lagging CI simulator this change diagnoses, a spurious serve arriving after 1s would go undetected (false pass). This window is unchanged from before the change (it was always 1s), is an inherent limitation of absence-assertions, and is explicitly documented in the new Waiter doc comment, so no action is needed.✅ **Test** - passed
✅ No issues found.
xcodebuild test -scheme StateManagement-Package -destination 'platform=iOS Simulator,name=iPhone 17' (the exact failing CI command; 267 tests in 51 suites, TEST SUCCEEDED)xcodebuild test-without-building ... -only-testing:StateManagement_Tests/ComputedTests -only-testing:StateManagement_Tests/DictionaryReadEntryPointTests -test-iterations 10 -run-tests-until-failure (keyedComputedRead and 'A Service reads the whole dictionary...' passed 10/10 iterations)xcodebuild test-without-building ... -only-testing:StateManagement_Tests/ReentrancyFirstWinsTests -test-iterations 25 -run-tests-until-failure (100/100 test executions passed, no hang)swift test --filter "ComputedTests|ReentrancyFirstWinsTests|RemoveValueTests|DictionaryReadEntryPointTests" (macOS regression check on affected suites, 20 tests passed)Verified in the iOS run log that computedUnrelatedMutations, keyedComputedUnrelatedChanges, and removingUnreadKeyDoesNotRecompute complete at ~1.22s, proving the shortened 1s must-not-serve deadline still fires Timeout as designed✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.