Skip to content

fix: wait up to five seconds for the creator of a timer to set it up - #1196

Merged
vbreuss merged 1 commit into
mainfrom
fix/longer-timer-set-up-wait
Nov 4, 2026
Merged

vbreuss merged 1 commit into
mainfrom
fix/longer-timer-set-up-wait

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 4, 2026

Copy link
Copy Markdown
Member

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 vbreuss self-assigned this Nov 4, 2026
@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Test Results

     80 files  ± 0       80 suites  ±0   1h 42m 52s ⏱️ + 1m 34s
 87 920 tests + 5   83 230 ✅ + 5   4 690 💤 ±0  0 ❌ ±0 
203 666 runs  +26  183 944 ✅ +26  19 722 💤 ±0  0 ❌ ±0 

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.
  )
)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(11e90da3-6535-4ccf-b2e7-52235f567e98)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(20c208aa-8929-4729-978c-ce51b3e5cb0c)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(283caf3b-7081-4328-9b6d-8821e36a461a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3345bf2a-818c-435e-8ed9-bd5c3e367544)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(39a53783-12e8-40cf-8d31-e21044b516d5)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3bc3b045-8be2-488e-95cf-4552f58bf1ac)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(403ddb3a-fd6b-4ecf-a41d-ff0c87bb3fe4)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(4c318ce9-3c6f-4b7f-8831-4670e6577fad)
…
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(08c12a52-eb75-423c-a303-5e6b65dcb5c9)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(0d2aefa7-c2be-4b86-8134-4c93db6129c0)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1c43a244-4853-44b4-a6cd-889c78cff1b6)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2486aaee-33c9-4808-9bcf-c05c81a94d39)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2636af29-b4e0-4c0b-89e1-350bbbb271d9)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3b6be133-7fed-4142-bd1d-af208c21a045)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3ff00c5c-fe6d-431f-8687-e54e3cb5338a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(58db9968-d5a8-4494-adc5-92b35dde2579)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(6c30b4d6-feda-40eb-b926-69a0d379f44f)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(78aaa015-678c-46d0-8e31-2e9def6ef5f3)
…
This pull request removes 4662 skipped tests and adds 4662 skipped tests. Note that renamed tests count towards both.
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(1c3ee2a8-4e93-40a1-8304-3e21ed244e14)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(6a69289a-6b45-4f6e-a09b-58cd578a571d)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(878ad994-54b8-453f-8772-52cd385f3804)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(92b658ac-e18c-4673-abfa-d6138c825432)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(93252ef2-b298-4a4c-a094-7795184976e5)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(d159087b-6845-47b3-bedc-085fe7adf387)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(dbfc79b7-2f2e-401e-8914-eb307fc1b005)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(e9bd73e8-8e99-4724-9fce-f6767a40f445)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(408743b2-0d9f-405f-b82e-58fdf5b9d5f7, None)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(646dca3e-72bd-47a1-90d5-3aabedaba654, None)
…
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(1b88c096-ece5-4dbc-89dc-dd15dc00f19f)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(1c5eec8b-fa8b-44fc-8e5d-b8f29ce85517)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(722c28a7-50a7-4a8a-a0b2-7c2f56b1725b)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(978b8086-0618-4e46-a26e-9c2112d24596)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(afe67c28-eebc-4dc2-aac7-bd3dec855b62)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(b27e0cca-b6b6-420e-9dd7-e3a5c7128cf1)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(c5d9668e-b0fd-446b-8156-bb0c32089ed8)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows(ec246ff9-bf99-48a8-822e-59a3ede28824)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(0b69c88c-3e7e-4dcd-a8cf-7df16a070b25, None)
Testably.Abstractions.Testing.Tests.FileSystem.FileMockTests ‑ SetUnixFileMode_SafeFileHandle_ShouldUpdateValue(813affab-cdb7-4fb1-aca0-a0d6c2b35463, None)
…

`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
vbreuss force-pushed the fix/longer-timer-set-up-wait branch from d7d0c2f to 5fcf8ef Compare November 4, 2026 15:56
@vbreuss
vbreuss merged commit c9d4f3a into main Nov 4, 2026
9 of 10 checks passed
@vbreuss
vbreuss deleted the fix/longer-timer-set-up-wait branch November 4, 2026 16:02
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

This is addressed in release v8.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant