Skip to content
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

[browser] [wasm] Make response streaming opt-out #111680

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

campersau
Copy link
Contributor

Enabling response streaming is a breaking change because sync reads are no longer allowed and throw NotSupportedExceptions.
All supported browsers support response streaming.

To disable response streaming (and allow sync reads) set WebAssemblyEnableStreamingResponse to false:

request.Options.Set(new HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingResponse"), false);

Part of #77904

Copy link
Member

@lewing lewing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support this in principle. I'm concerned about how the breaking change will surface to people upgrading. My assumption is that it at the moment it will only show up at runtime?

@campersau
Copy link
Contributor Author

Yes, it will only show up at runtime. Similar to Kestrels AllowSynchronousIO defaulting to false.
The main issue I will have with dotnet/runtime types is that ZipArchive does not support async #1541 and would throw.
An other workaround is to buffer the stream manually.

Could we add an app context switch to toggle this globally?

}

responseMessage.Content = streamingResponseEnabled
responseMessage.Content = (_request.Options.TryGetValue(EnableStreamingResponse, out var streamingResponseEnabled) ? streamingResponseEnabled : true) && BrowserHttpInterop.SupportsStreamingResponse()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all browsers support response streaming, should we remove BrowserHttpInterop.SupportsStreamingResponse?

@pavelsavara pavelsavara added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Jan 22, 2025
Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Net.Http community-contribution Indicates that the PR has been added by a community member os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants