Repository navigation
fix: wait up to five seconds for the creator of a timer to set it up - #1196
Merged
Merged
Conversation
|
This pull request is merged. |
Test Results 80 files ± 0 80 suites ±0 1h 42m 52s ⏱️ + 1m 34s Results for commit d7d0c2f. ± Comparison against base commit e17e04d. This pull request removes 84586 and adds 84590 tests. Note that renamed tests count towards both.This pull request removes 4662 skipped tests and adds 4662 skipped tests. Note that renamed tests count towards both. |
`Task.Delay(TimeSpan, TimeProvider, CancellationToken)` registers its token only after it created its timer, so the timers that advance the clock wait until the delay registered it (#1188). That wait was bounded by the same one second of real time as a blocked callback. On a loaded machine, the creator's thread may not run for that long, and the delay's timer then fires before its token is registered: a timeout that is due earlier no longer cancels the delay, and the timers silently fire in another order. The wait now has its own limit of 5 seconds. It only takes that long for a creator that never finishes, e.g. a delay with the token of a disposed `CancellationTokenSource`, which never registers; such a delay now holds the clock for 5 instead of 1 second of real time, once for each such timer. This is documented on the auto-advance page. The wait still spins outside of all locks, so it blocks neither the creator nor other threads that move the clock. A test that fails with the old limit pins the longer wait, and another one pins that a creator that never finishes does not stop the clock.
vbreuss
force-pushed
the
fix/longer-timer-set-up-wait
branch
from
November 4, 2026 15:56
d7d0c2f to
5fcf8ef
Compare
|
|
This is addressed in release v8.0.0. |
This was referenced Nov 11, 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.



Task.Delay(TimeSpan, TimeProvider, CancellationToken)registers its token only after it created its timer, so the timers that advance the clock wait until the delay registered it (#1188). That wait was bounded by the same one second of real time as a blocked callback. On a loaded machine, the creator's thread may not run for that long, and the delay's timer then fires before its token is registered: a timeout that is due earlier no longer cancels the delay, and the timers silently fire in another order.The wait now has its own limit of 5 seconds. It only takes that long for a creator that never finishes, e.g. a delay with the token of a disposed
CancellationTokenSource, which never registers; such a delay now holds the clock for 5 instead of 1 second of real time, once for each such timer. This is documented on the auto-advance page. The wait still spins outside of all locks, so it blocks neither the creator nor other threads that move the clock.A test that fails with the old limit pins the longer wait, and another one pins that a creator that never finishes does not stop the clock.