Skip to content

[Breaking change]: [browser] streaming HTTP response is on by deafult #45644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 3 tasks
pavelsavara opened this issue Apr 7, 2025 · 0 comments · Fixed by #45667
Closed
1 of 3 tasks

[Breaking change]: [browser] streaming HTTP response is on by deafult #45644

pavelsavara opened this issue Apr 7, 2025 · 0 comments · Fixed by #45667
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 10 Work items for the .NET 10 release 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@pavelsavara
Copy link
Member

pavelsavara commented Apr 7, 2025

Description

This breaking change introduces default support for streaming HTTP responses in browser HTTP clients, which previously required opt-in. This enhancement leverages the capabilities of modern evergreen browsers to improve memory consumption and responsiveness, particularly for large data requests and scenarios like streaming AI chat responses. However, developers should be aware that the response.Content.ReadAsStreamAsync() method will now return a BrowserHttpReadStream instead of a MemoryStream, which does not support synchronous operations. This change may impact existing code that relies on synchronous stream operations.

See dotnet/runtime#111680 for details

Version

.NET 10 Preview 3

Previous behavior

In the Browser/Wasm/Blazor, previously the C# HTTP client buffered the whole response and the HttpContent contained full MemoryStream by default. Unless you opted in via WebAssemblyEnableStreamingResponse HttpRequestOption which enabled the streaming response, typical on other operating systems.

New behavior

The WebAssemblyEnableStreamingResponse is now opt-out instead of opt-in. The HttpContent is not MemoryStream by default.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

To aid use-cases around streaming GetFromJsonAsAsyncEnumerable which work by default on other OSes.

Recommended action

If you need to disable it globally, you can use

set env variable DOTNET_WASM_ENABLE_STREAMING_RESPONSE

We plan to make the <WasmEnableStreamingResponse>false</WasmEnableStreamingResponse> in your project file for in future previews of Net 10. See dotnet/runtime#97449

To disable it for individual request, you can use existing
request.Options.Set(new HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingResponse"), false);
or request.SetBrowserResponseStreamingEnabled(false) extension in Blazor project

Feature area

Networking

Affected APIs

No response


Associated WorkItem - 418815

@pavelsavara pavelsavara added the breaking-change Indicates a .NET Core breaking change label Apr 7, 2025
@dotnet-policy-service dotnet-policy-service bot added the ⌚ Not Triaged Not triaged label Apr 7, 2025
@CamSoper CamSoper added 🏁 Release: .NET 10 Work items for the .NET 10 release and removed ⌚ Not Triaged Not triaged labels Apr 7, 2025
@dotnetrepoman dotnetrepoman bot added the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 7, 2025
@dotnet-policy-service dotnet-policy-service bot removed the 🗺️ mapQUEST Only used as a way to mark an issue as updated for quest. RepoMan should instantly remove it. label Apr 7, 2025
@CamSoper CamSoper moved this from 🔖 Ready to 🏗 In progress in dotnet/docs April 2025 sprint project Apr 7, 2025
@CamSoper CamSoper moved this from 🏗 In progress to 🔖 Ready in dotnet/docs April 2025 sprint project Apr 7, 2025
@CamSoper CamSoper added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Apr 7, 2025
@CamSoper CamSoper moved this from 🔖 Ready to 🏗 In progress in dotnet/docs April 2025 sprint project Apr 7, 2025
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Apr 8, 2025
CamSoper added a commit to CamSoper/dotnet.docs that referenced this issue Apr 8, 2025
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in dotnet/docs April 2025 sprint project Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 10 Work items for the .NET 10 release 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants