Summary
DictionaryExtensions.TryAddValuesAsync cancels its inner Task.Run after a hard-coded 500 ms wall-clock window. Under parallel test execution with coverage instrumentation the thread pool can delay the task start past that window, so DictionaryExtensions_Tests.TryAddValuesAsync_UpdatesExistingValue fails intermittently with TaskCanceledException even though the operation itself completes in about 2 ms when run alone.
Environment
- OS/version: Windows 11 Pro 10.0.26200, .NET Framework 4.8.1 test host (VSTest 18.9.0, MSTest 4.4.0)
- Python version: n/a
- Command/flags used:
vstest.console.exe UtilitiesCS.Test.dll VBFunctions.Test.dll /EnableCodeCoverage /InIsolation /Logger:trx "/TestCaseFilter:TestCategory!=LiveOutlook" (MSTest assembly-level parallelization enabled: 24 workers, class-level scope)
- Data source or fixture: none; in-memory
ConcurrentDictionary<string,int>
Steps to Reproduce
- Build the solution in Debug.
- Run
UtilitiesCS.Test.dll together with another assembly under /EnableCodeCoverage on a machine where the thread pool is saturated (24 parallel class workers).
- Observe
TryAddValuesAsync_UpdatesExistingValue occasionally reported as failed after roughly 20 s.
- Re-run
/TestCaseFilter:FullyQualifiedName~DictionaryExtensions_Tests alone: all 14 tests pass, the affected test in about 2 ms.
Expected Behavior
TryAddValuesAsync returns true and updates the value regardless of thread-pool scheduling latency, and the unit test is deterministic under parallel execution.
Actual Behavior
Intermittent failure (observed 2026-09-04 during PR #779 verification):
Test method UtilitiesCS.Test.Extensions.DictionaryExtensions_Tests.TryAddValuesAsync_UpdatesExistingValue threw exception:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at UtilitiesCS.DictionaryExtensions.<TryAddValuesAsync>d__10`2.MoveNext() in UtilitiesCS\Extensions\DictionaryExtensions.cs:line 179
Logs / Screenshots
Impact / Severity
Flaky CI failures on unrelated pull requests; production callers may receive a spurious TaskCanceledException under thread-pool starvation.
Source
From: docs/features/potential/2026-09-04-tryaddvaluesasync-wall-clock-timeout-flaky.md
Summary
DictionaryExtensions.TryAddValuesAsynccancels its innerTask.Runafter a hard-coded 500 ms wall-clock window. Under parallel test execution with coverage instrumentation the thread pool can delay the task start past that window, soDictionaryExtensions_Tests.TryAddValuesAsync_UpdatesExistingValuefails intermittently withTaskCanceledExceptioneven though the operation itself completes in about 2 ms when run alone.Environment
vstest.console.exe UtilitiesCS.Test.dll VBFunctions.Test.dll /EnableCodeCoverage /InIsolation /Logger:trx "/TestCaseFilter:TestCategory!=LiveOutlook"(MSTest assembly-level parallelization enabled: 24 workers, class-level scope)ConcurrentDictionary<string,int>Steps to Reproduce
UtilitiesCS.Test.dlltogether with another assembly under/EnableCodeCoverageon a machine where the thread pool is saturated (24 parallel class workers).TryAddValuesAsync_UpdatesExistingValueoccasionally reported as failed after roughly 20 s./TestCaseFilter:FullyQualifiedName~DictionaryExtensions_Testsalone: all 14 tests pass, the affected test in about 2 ms.Expected Behavior
TryAddValuesAsyncreturnstrueand updates the value regardless of thread-pool scheduling latency, and the unit test is deterministic under parallel execution.Actual Behavior
Intermittent failure (observed 2026-09-04 during PR #779 verification):
Logs / Screenshots
Impact / Severity
Flaky CI failures on unrelated pull requests; production callers may receive a spurious
TaskCanceledExceptionunder thread-pool starvation.Source
From: docs/features/potential/2026-09-04-tryaddvaluesasync-wall-clock-timeout-flaky.md