You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ProcessTreeCpuSamplerTests.Finds_A_Real_Child_Process_Until_It_Exits fails on Windows: exited child's ID still reported #7909
ProcessTreeCpuSamplerTests.Finds_A_Real_Child_Process_Until_It_Exits failed on a Windows CI runner: after the sort child exited and was disposed, a second TryRead still returned its process ID. The test asserts that ID is absent, so it fails whenever Windows still reports that ID as one of our descendants after exit. The change under test in that PR did not touch the sampler or this test.
failed Finds_A_Real_Child_Process_Until_It_Exits (382ms)
AssertionException: Expected to not contain 8228
but the item was found in the collection
at Assert.That(processes.Keys).DoesNotContain(childId)
Likely causes
Either is consistent with the failure; neither is excluded by the reader or the test today:
The exited process is still visible. A Windows process object persists while any handle to it stays open, and GetProcessTimes succeeds on an exited process. The reader does not check whether a process is still running (GetExitCodeProcess / STILL_ACTIVE), so a lingering handle (another component's, or antivirus on the runner) keeps the ID in the result.
The ID was reused. Windows reuses process IDs quickly. Other tests in TUnit.UnitTests start child processes in parallel, so the ID can belong to a new descendant created after ours. The test checks only the ID, not the start time it saw first.
Reproduction
Not deterministic. Run TUnit.UnitTests on a loaded Windows machine with tests in parallel; the failure needs the child's ID to stay listed after WaitForExitAsync returns.
Expected
The test fails only when the reader reports a process that has really exited. Suggested fix: compare by identity rather than by ID alone (assert no entry has the child's ID and its first-seen StartTime), and have the Windows reader skip processes whose exit code is no longer STILL_ACTIVE.
Can the reader be changed to drop exited processes, and the test to match on start time as well as ID?
Seen again on PR #7898 (run 46314133323, modularpipeline windows-latest): Finds_A_Real_Child_Process_Until_It_Exits failed with "Expected to not contain 3704". It is unrelated to that PR's change. I reran the failed job.
failed Finds_A_Real_Child_Process_Until_It_Exits (230ms)
AssertionException: Expected to not contain 9400
but the item was found in the collection
at Assert.That(processes.Keys).DoesNotContain(childId)
at TUnit.UnitTests.ProcessTreeCpuSamplerTests.Finds_A_Real_Child_Process_Until_It_Exits() in tests/TUnit.UnitTests/ProcessTreeCpuSamplerTests.cs:512
It was the only failure of 1,447 tests in TUnit.UnitTests (net10.0) in that job. That PR does not change ProcessTreeCpuSampler, its readers or this test.
Activity
thomhurst commentedon Nov 29, 2026
Seen again on
modularpipeline (windows-latest)for #7910: https://github.com/thomhurst/TUnit/actions/runs/46312567345/job/141502077944 (Expected to not contain 9276 but the item was found in the collection, atProcessTreeCpuSamplerTests.cs:481). The machine was at 100% CPU at the time.thomhurst commentedon Nov 29, 2026
Seen again on PR #7898 (run 46314133323, modularpipeline windows-latest):
Finds_A_Real_Child_Process_Until_It_Exitsfailed with "Expected to not contain 3704". It is unrelated to that PR's change. I reran the failed job.thomhurst commentedon Nov 30, 2026
Seen again on
windows-latest, inmodularpipeline (windows-latest)for PR #7916 at commit17e55de864: https://github.com/thomhurst/TUnit/actions/runs/46496165319/job/142121980571It was the only failure of 1,447 tests in
TUnit.UnitTests(net10.0) in that job. That PR does not changeProcessTreeCpuSampler, its readers or this test.fix(engine): start added lane workers under the scheduler's context, …
thomhurst commentedon Nov 30, 2026
Failed again on PR #7916 at
609fc3bf76(https://github.com/thomhurst/TUnit/actions/runs/46503201172/job/142146430947,Expected to not contain 3076), the second run in a row there. That PR now carries the fix in 06c7b9d:WindowsProcessTreeReader.TryReadTimesskips a process whose exit time is set, and the test compares the start time as well as the ID. This issue can close when #7916 merges.