test(CM0001): observe a cancelled request's disconnect off the thread pool; overwrite test-result artifacts on re-run - #573
Merged
Arthurvdv merged 2 commits intoSep 28, 2026
Conversation
… pool The cancellation test raced the fake server's ReadAsync-based disconnect observation against a two-second Task.Delay. The client closes its socket synchronously inside Cancel(), but observing that through task continuations needs more thread-pool hops than the timer, so a saturated CI runner let the timer win and reported a false "not prompt" while the later assertions still proved cancellation had propagated. Observe the disconnect with a blocking read on a dedicated thread that sets a ManualResetEventSlim, and wait on that signal. The window and every assertion are unchanged; the blocking read is bounded by the server's shutdown budget because the shutdown token cannot interrupt it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Artifacts are stored per run attempt. Re-running a single test leg left two test-results-<version> artifacts and two unified test-results artifacts, so the merge job picked up the stale attempt-1 trx and the Test Report check listed every trx twice with the already-fixed failure still red. Set overwrite: true on both uploads so a re-run replaces the same-named artifact and the report reflects the latest attempt. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Arthurvdv
deleted the
fix/cm0001-cancellation-test-disconnect-observation
branch
September 28, 2026 12:17
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.
Summary
Fixes the flaky
CancelledCompilation_ClosesHttpRequestPromptly_AndNextCompilationRecoverstest inALCops.Common.Testand the stale "Test results" check after a single-leg re-run. Both surfaced on #571 (run 36340330338), which does not touch Common; the failure is unrelated to that PR.What happened
closedPromptlyfailed.nextwas empty andRequestCount == 2passed, so cancellation had propagated and nothing was cached. The 2 sTask.Delayrace won on a slow shared runner.test-results-12.1.13.35966and twotest-resultsartifacts (one per attempt).download-artifactpicked up the attempt-1 per-version artifact, so even the attempt-2 unified artifact contained the failing trx, and dorny downloaded both unified artifacts.Mechanism
Cancel()runs the linked-token registrations inline (test token → SDK linked CTS →HttpClientlinked CTS →HttpConnection.Dispose), so the client socket is closed beforeCancel()returns. The fake server observed that withReadAsyncplus aRunContinuationsAsynchronouslycompletion feedingTask.WhenAny, which needs more thread-pool hops than the timer it raced. On a saturated pool the timer wins although the close was immediate.Changes
NetworkStream.Readon aLongRunningtask that sets aManualResetEventSlim; the test waits on that signal. The 2 s window and every assertion are unchanged. The blocking read is bounded by the server's shutdown budget because the shutdown token cannot interrupt it.overwrite: trueon the per-version and unified test-result uploads inbuild-test.yml, so a re-run replaces the same-named artifact.testing.md(Concurrent synchronous HTTP tests), the CM0001 rule doc test notes, andrelease-strategy.md(Test report gate) record the why.Verification
DOTNET_ThreadPool_MinThreads=2/MaxThreads=3: 20/20 passed, so the flake did not reproduce on this Windows machine. The fix rests on the mechanism above and the attempt-1 log evidence.ALCopsSettingsRemoteRecoveryTestsfixture without pressure: 10/10 runs passed. FullALCops.Common.Testsuite: 159 passed.dotnet format ALCops.sln --verify-no-changesclean;Validate-Rules.ps1OK.🤖 Generated with Claude Code