Open radderz opened 1 month ago
https://github.com/radderz/BlazorAppJsonStreamBug
You can run the asp.net core project, which is hosting the web assembly page, once you are on the page and the timer is updating, kill the asp.net core api projects process (don't gracefully shut it down, do a kill) and you'll see the unhandled network error.
Thanks for the report. Can this be reproduced without IAsyncEnumerable
? Also, when there is no network error, does JsonSerializer.DeserializeAsyncEnumerable<List<AssetState>>(stream)
give you access to the array items before the entire array is complete? I would have expected you to need to use IAsyncEnumerable
rather than List
for the generic parameter.
Thanks for the report. Can this be reproduced without
IAsyncEnumerable
? Also, when there is no network error, doesJsonSerializer.DeserializeAsyncEnumerable<List<AssetState>>(stream)
give you access to the array items before the entire array is complete? I would have expected you to need to useIAsyncEnumerable
rather thanList
for the generic parameter.
I don't think it is really related to IAsync Enumerable, it's more the streaming http endpoint. It could be a non dotnet api.
I think this is more on the wasm side.
Yes I get the results streaming imediately (which is the whole point of the streaming api) before the network error when the connection fails mid way ungracefully. If I close the connection gracefully on either side this doesn't happen. It's good for streaming down real time changes. I could use a different technology potentially like websockets but this is convenient.
I haven't tested if this happens for a long running standard http get request where the server drops mid request.
Sorry I take that back, even gracefully closing the connection from the server side also results in this unhandled error.
Thanks for the report. Can this be reproduced without
IAsyncEnumerable
? Also, when there is no network error, doesJsonSerializer.DeserializeAsyncEnumerable<List<AssetState>>(stream)
give you access to the array items before the entire array is complete? I would have expected you to need to useIAsyncEnumerable
rather thanList
for the generic parameter.
Hi @halter73, I forgot to answer the generic part, the response I am sending is an IAsyncEnumerable<List
Is there an existing issue for this?
Describe the bug
When using IAsyncEnumerable response type from an asp.net core API and using WebAssemblyEnableStreamingResponse if there is a network error, an unhandled exception is thrown outside of the caller scope.
i.e. there is no way to catch the error and this ends up displaying a Blazor UI error that cannot be controlled. It doesn't break anything and the site just continues working, but the error shows up in the console and shows an error popup on the UI.
A try catch around this doesn't suppress the error.
The below image shows the error in the console, you can see the console write line in between from the catch, but there is still an unhandled error outside the scope.
Expected Behavior
Steps To Reproduce
The steps are a reasonably simple but the blazor UI needs to be connected to an api with the ability to remove connectivity (i.e. pulling out the network cable or disconnect wifi). So the api needs to be on a different machine or be isolatable from the browser running the blazor wasm UI. Possibly devtunnels would make this easy to reproduce.
Exceptions (if any)
Error in http_wasm_abort_response: TypeError: network error
.NET Version
8.0.300
Anything else?
No response