In .NET 9 preview 5 blazor WASM with chromium browsers, when using request streaming, HttpRequestException
is thrown unexpectedly if a response is sent before the stream is fully sent to the server
#104612
Labels
arch-wasm
WebAssembly architecture
area-System.Net.Http
in-pr
There is an active PR which will close this issue when it is merged
os-browser
Browser variant of arch-wasm
Milestone
Description
While trying the new
SetBrowserRequestStreamingEnabled
feature for ``HttpRequestMessage` in .NET9 Blazor WASM, I have noticed a blocking behaviour when returning non-success status code from my API calls while streaming something during the request.Instead of returning a
HttpResponseMessage
that I can manipulate when returning non 2xx codes, theSendAsync
method simply triggers aHttpRequestException
.After more tests, I have found that it is happening with any status code as long as the response is sent before the body is fully streamed to the server. I also believe this issue is only happening on Chromium browsers as Firefox is following the expected behaviour below.
Reproduction Steps
Error message is "Bad request message returned"
Expected behavior
Like when request streaming is disabled, no exception is thrown and I can manipulate the response as wanted.
Actual behavior
An exception is thrown on the
SendAsync
method call.Regression?
No response
Known Workarounds
The server must read the entirety of the body
Configuration
Other information
Most likely linked to a missing exception handling there #91699
If I change the post endpoint to the following code to make sure that the request stream is fully read, no exception is thrown.
Stack trace:
The text was updated successfully, but these errors were encountered: