Skip to content

Make WinHTTP cancellation test use a synchronized loopback server - #136829

Merged
rzikm merged 2 commits into
dotnet:mainfrom
rzikm:rzikm/winhttp-cancellation-failure-burst
Nov 2, 2026
Merged

rzikm merged 2 commits into
dotnet:mainfrom
rzikm:rzikm/winhttp-cancellation-failure-burst

Conversation

@rzikm

@rzikm rzikm commented Nov 2, 2026

Copy link
Copy Markdown
Member

The cancellation test assumes httpbin's delay=40 request is still pending when it cancels after 500 ms. That URL now returns HTTP 400 with invalid delay: duration 40s longer than 10s; native WinHTTP received it locally in 345 ms. A completed HTTP response makes the existing exception assertion fail, and the unmodified source test reproduced the CI signature on both target frameworks.

Use the existing loopback server and cancel after it has read the request, without sending a response. This removes the external dependency and fixed delay while preserving the exact AggregateException and inner TaskCanceledException assertions. The test can now run in innerloop. No product code changes.

The recent CI burst has historical identical failures. The endpoint's change date and actual CI responses were not captured, so this does not establish a newly introduced WinHTTP product regression.

Validation

Commands ran through an owned short subst path against locally built sources:

  • build.cmd clr+libs -rc release: passed, 0 warnings and 0 errors.
  • dotnet.cmd build src\libraries\System.Net.Http.WinHttpHandler\tests\FunctionalTests\System.Net.Http.WinHttpHandler.Functional.Tests.csproj /t:Test /p:RuntimeConfiguration=Release /p:OuterLoop=true /p:XunitMethodName=System.Net.Http.WinHttpHandlerFunctional.Tests.WinHttpHandlerTest.SendAsync_SlowServerAndCancel_ThrowsTaskCanceledException: before the fix, failed with the identical no-exception assertion on net12.0-windows and net481, one test each.
  • dotnet.cmd build src\libraries\System.Net.Http.WinHttpHandler\tests\FunctionalTests\System.Net.Http.WinHttpHandler.Functional.Tests.csproj /t:Test /p:RuntimeConfiguration=Release /p:XunitMethodName=System.Net.Http.WinHttpHandlerFunctional.Tests.WinHttpHandlerTest.SendAsync_SlowServerAndCancel_ThrowsTaskCanceledException: after the fix, passed on both frameworks, one test each, no skips.
  • dotnet.cmd build src\libraries\System.Net.Http.WinHttpHandler\tests\FunctionalTests\System.Net.Http.WinHttpHandler.Functional.Tests.csproj /t:Test /p:RuntimeConfiguration=Release: passed; net12.0-windows had 1,743 passed and 43 skipped, net481 had 653 passed and 29 skipped, no failures.
  • dotnet.cmd build src\libraries\System.Net.Http.WinHttpHandler\tests\UnitTests\System.Net.Http.WinHttpHandler.Unit.Tests.csproj /t:Test /p:RuntimeConfiguration=Release: passed, 173 tests, no failures or skips.

Full external-server outerloop, other Windows versions/architectures, and Mono validation were not run.

Note

This pull request description and code change were generated with GitHub Copilot.

Replace the invalid httpbin 40-second delay dependency with a local server that reads the request without sending a response. Cancel only once the request is pending, preserve the exact exception assertions, and run the test in innerloop.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@rzikm
rzikm requested a review from a team November 2, 2026 10:11
@rzikm
rzikm requested a review from MihaZupan November 2, 2026 11:35
@rzikm
rzikm enabled auto-merge (squash) November 2, 2026 12:09
@rzikm
rzikm merged commit 480b65a into dotnet:main Nov 2, 2026
84 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
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.

2 participants