Skip to content

[wasm][browser] BrowserHttpHandler_StreamingRequest_Http1Fails throws TaskCanceledException instead of HttpRequestException #129758

Description

@radekdoulik

Description

System.Net.Http.Functional.Tests.SocketsHttpHandler_ResponseStreamTest.BrowserHttpHandler_StreamingRequest_Http1Fails (source: src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs) fails on Browser + CoreCLR (wasm) but passes on Browser + Mono (wasm).

The test sends a streaming (WebAssemblyEnableStreamingRequest) POST over HTTP/1 and expects the browser fetch to reject it quickly:

HttpRequestException ex = await Assert.ThrowsAsync<HttpRequestException>(() => client.SendAsync(req));
Assert.Equal("TypeError: Failed to fetch", ex.Message);

On CoreCLR-wasm the request instead hangs and is canceled by the 100s HttpClient.Timeout:

Assert.Throws() Failure: Exception type was not an exact match
Expected: typeof(System.Net.Http.HttpRequestException)
Actual:   typeof(System.Threading.Tasks.TaskCanceledException)
---- System.Threading.Tasks.TaskCanceledException : The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
-------- System.TimeoutException : The operation was canceled.
------------ System.Threading.Tasks.TaskCanceledException : The operation was canceled.
---------------- System.Runtime.InteropServices.JavaScript.JSException : Error: OperationCanceledException
   at System.Net.Http.BrowserHttpInterop.CancellationHelper(Task promise, CancellationToken cancellationToken, JSObject jsController)

This indicates the streaming-request-over-HTTP/1 rejection path that produces TypeError: Failed to fetch is not being hit on CoreCLR-wasm (the request appears to proceed instead of failing fast).

How it was found

Discovered while bringing up the new scheduled Browser + CoreCLR outerloop libraries-test lane (#129436). This [OuterLoop] browser test had never run in CI before (Mono runs innerloop only).

Workaround

The test is being gated to skip on CoreCLR-wasm only, keeping Mono-wasm coverage:

[ActiveIssue("https://github.com/dotnet/runtime/issues/<this-issue>", typeof(PlatformDetection), nameof(PlatformDetection.IsNotMonoRuntime))]

(The test is already [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowser))], so the ActiveIssue only takes effect on Browser + CoreCLR.)

Note

This issue was created by GitHub Copilot on behalf of the user.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions