Skip to content

[wasi] Fix flaky PostAsync_CancelDuringRequestContentSend_TaskCanceledQuickly with WasiHttpHandler - #137535

Merged
lewing merged 1 commit into
dotnet:mainfrom
lewing:lewing-wasi-cancel-content-send-flaky
Nov 14, 2026
Merged

lewing merged 1 commit into
dotnet:mainfrom
lewing:lewing-wasi-cancel-content-send-flaky

Conversation

@lewing

@lewing lewing commented Nov 14, 2026

Copy link
Copy Markdown
Member

PostAsync_CancelDuringRequestContentSend_TaskCanceledQuickly intermittently times out in System.Net.Http.WasiHttpHandler.Functional.Tests on WASI (#137534).

The failure is the loopback harness's 60s TimeoutException, not the cancellation assertion. When the request is canceled while its body is being sent, the wasi:http host can abandon the request before it connects to the loopback server. The server side then waits in AcceptConnectionAsync until the harness times out.

For WasiHttpHandler, the server side now completes once the client side is done, the same way SendAsync_Expect100Continue_RequestBodyFails_ThrowsContentException and PostAsync_Cancel_CancellationTokenPassedToContent already handle this race. Other handlers are unchanged.

Validation

  • CoreCLR WASI, Release, wasmtime 49.0.1: WasiHttpHandler_HttpClientHandler_Cancellation_Test passed 5 of 5 runs (43/43 each). The race didn't reproduce locally, so this confirms no regression rather than reproducing the fix.
  • System.Net.Http.Functional.Tests builds for WASI with the change.

Resolves #137534

Note

This PR description and the change were generated with GitHub Copilot.

With WasiHttpHandler the wasi:http host can abandon a canceled request before
it connects to the loopback server, leaving AcceptConnectionAsync waiting until
the loopback timeout. Let the server side complete once the client is done, as
the other request-content tests already do for WasiHttpHandler.

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

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 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.

@lewing
lewing enabled auto-merge (squash) November 14, 2026 03:07
@lewing
lewing merged commit 87c4127 into dotnet:main Nov 14, 2026
65 of 67 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 19, 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.

Hang: WasiHttpHandler_HttpClientHandler_Cancellation_Test.PostAsync_CancelDuringRequestContentSend_TaskCanceledQuickly times out on WASI

2 participants