Fix flakey scheduled callback cancellation tests on iOS simulator#3556
Merged
rnro merged 1 commit intoapple:mainfrom Mar 20, 2026
Merged
Fix flakey scheduled callback cancellation tests on iOS simulator#3556rnro merged 1 commit intoapple:mainfrom
rnro merged 1 commit intoapple:mainfrom
Conversation
Motivation * `MTELGScheduledCallbackTests.testCancelAfterShutdownDoesNotCallCancellationCallbackAgain` is failing on iOS simulator CI. It schedules a callback with a `.milliseconds(1)` deadline, then shuts down, expecting shutdown to cancel the callback. On the simulator the 1ms timer fires before shutdown processes, so the callback executes instead of being cancelled. * This is the same class of bug previously fixed for `testScheduledCallbackNotExecutedBeforeDeadline` in dcecf0c. Modifications * Change the scheduled callback deadline from `.milliseconds(1)` to `.hours(1)` in `testCancelAfterShutdownDoesNotCallCancellationCallbackAgain` (the observed failure). * Speculatively apply the same fix to `testCancelExecutesCancellationCallback`, `testCancelAfterCancelDoesNotCallCancellationCallbackAgain`, and `testShutdownDoesNotCancelCancelledCallbacksAgain` which have the same pattern. * The `EmbeddedEventLoop` and `NIOAsyncTestingEventLoop` subclasses use virtual time so this does not extend test duration. Result * Scheduled callback cancellation tests no longer depend on real-time precision and should not flake on slow CI runners or simulators.
glbrntt
approved these changes
Mar 20, 2026
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.
Motivation
MTELGScheduledCallbackTests.testCancelAfterShutdownDoesNotCallCancellationCallbackAgainis failing on iOS simulator CI. It schedules a callback with a.milliseconds(1)deadline, then shuts down, expecting shutdown to cancel the callback. On the simulator the 1ms timer fires before shutdown processes, so the callback executes instead of being cancelled.testScheduledCallbackNotExecutedBeforeDeadlinein dcecf0c.Modifications
.milliseconds(1)to.hours(1)intestCancelAfterShutdownDoesNotCallCancellationCallbackAgain(the observed failure).testCancelExecutesCancellationCallback,testCancelAfterCancelDoesNotCallCancellationCallbackAgain, andtestShutdownDoesNotCancelCancelledCallbacksAgainwhich have the same pattern.EmbeddedEventLoopandNIOAsyncTestingEventLoopsubclasses use virtual time so this does not extend test duration.Result