Skip to content

Bug: tryaddvaluesasync-wall-clock-timeout-flaky #780

Description

@drmoisan
  • Work Mode: full-bug

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

  1. Build the solution in Debug.
  2. Run UtilitiesCS.Test.dll together with another assembly under /EnableCodeCoverage on a machine where the thread pool is saturated (24 parallel class workers).
  3. Observe TryAddValuesAsync_UpdatesExistingValue occasionally reported as failed after roughly 20 s.
  4. 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

  • Attached minimal logs or screenshot
  • Snippet: see Actual Behavior. Local run summary: 4767 tests, 4766 passed, 1 failed (this test), total time 35 s; the failing test alone took 21 s.

Impact / Severity

  • Blocker
  • High
  • Medium
  • Low

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

Activity

  1. drmoisan commented on Sep 8, 2026

    @drmoisan
    OwnerAuthor

    Consolidated into #811 on 2026-09-07 (maintainer decision: batch review residuals by blast radius). All acceptance criteria from this issue are carried in #811; this issue is closed as superseded, not as fixed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions