-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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] Request Streaming upload #91295
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsUses a It currently tries to get the buffer size from the browser via Exceptions from reading the I added some Do I need to adjust something regarding Fixes ##36634
|
8a16719
to
df3b0c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@campersau thanks for doing this! I really appreciate it.
I left few initial comments. Overall it seems sound implementation to me.
Do we have test for both streaming request and streaming response on same call ?
Do we dispose all the JSObject we transmit ?
Could the pull
callback become static ? (so that it doesn't allocate for Delegate)
Regarding FEATURE_WASM_THREADS, I think you don't have to do anything about it and it would already work.
I plan to re-write it once more for MT, because I would like to dispatch the calls more asynchronously. Currently it's synchronously blocking the caller, which is not great. And to be able to do that I will have to do more shuffling with the way how pointers/buffers are pinned (on caller stack).
I don't know details yet. But overall it means I will do it for your new code as well.
I added a test which does async request and response streaming in 487ef33
JSObject controller now gets disposed in e2193e6
I made it static and moved all the state to a separate class which is send to JS and then back to .NET in 92ae132 |
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Show resolved
Hide resolved
src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs
Outdated
Show resolved
Hide resolved
I like it as it is now, @maraf could you please review it ? |
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
I would like to see |
The |
We have plenty of things similar to Also |
I think it is because of this: runtime/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs Lines 643 to 647 in f470200
If I remove that attribute and run
I get failure, but I am not sure why it is this one..
|
This is NodeJS It doesn't run the test because runtime/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs Line 643 in f470200
Which is OK |
@pavelsavara ... The issue and PR are marked for 9.0 milestone. I just want to confirm that this will indeed be for 9.0. |
I didn't plan to backport this to Net8, it's too late for that I think. @lewing your expectations ? |
I noticed that the implementation uses For example:
The issue is that the stream produced by |
@greenEkatherine, @CarnaViire any thought on the feedback above ? |
We could change the implementation to use |
Uses a
ReadableStream
as fetch request body and reads chunks from .NETHttpContent
stream.The feature needs to be enabled via
HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingRequest")
. A helper could be added toWebAssemblyHttpRequestMessageExtensions
.It is only supported using HTTP/2 or higher and is currently only implemented in Chromium (Chrome / Edge) (see #36634 (comment)).
It currently tries to get the buffer size from the browser viadesiredSize
which in my testing was always0
. We can also remove this detection and just use the fixed default buffer size.I also enabled
autoAllocateChunkSize
which provides us abyobRequest
so we can copy directly into the browsers request buffer. Unfortunately WebAssembly/design#1162 is not yet implemented which means we can't do a zero-byte transfer by passing theArrayBuffer
to .NET and avoid any buffers in .NET.The default buffer size is currently set to
65536
. Maybe it should also be made configurable via aHttpRequestOptionsKey
?Exceptions from reading the
HttpContent
stream will fail the request with the thrown exception.The special case for
StringContent
is still preferred and bypasses streaming.I added some
BrowserHttpHandler_*
tests toResponseStreamTest.cs
analog to theWebAssemblyEnableStreamingResponse
one. Maybe theseBrowserHttpHandler_*
test should be moved in their own file?I duplicated the
PostAsync_ThrowFromContentCopy_RequsetFails
tests to use remote server, as theHttp2LoopbackServer
does not work in the browser.Do I need to adjust something regarding
FEATURE_WASM_THREADS
?Fixes #36634