-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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] Refactor Request Streaming to use HttpContent.CopyToAsync #91699
[browser] [wasm] Refactor Request Streaming to use HttpContent.CopyToAsync #91699
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsUses a Ref: #91295 (comment)
|
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.
Nice work thanks!
I wonder if the transformer could also improve response streaming :)
src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs
Outdated
Show resolved
Hide resolved
src/mono/wasm/runtime/http.ts
Outdated
// the bufferPtr is pinned by the caller | ||
const view = new Span(bufferPtr, bufferLength, MemoryViewType.Byte); | ||
const copy = view.slice() as Uint8Array; | ||
await ts.__writer.write(copy); |
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.
I would love this to be cancellable.
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.
I assume this may throw when
- TPC breaks or server kills the connection mid flight
- we triggered AbortController
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.
Unfortunately not, I need to race all of these with the fetch_promise_control
e.g.
await Promise.race([ts.__writer.write(copy), ts.__fetch_promise_control.promise]);
or do you have another idea?
var t = new TransformStream();
var w = t.writable.getWriter();
var a = new AbortController();
var f = fetch("", {
method: "POST",
body: t.readable,
duplex: "half",
signal: a.signal
});
a.abort();
var wp = w.write(new Uint8Array([1, 2, 3]));
var done = Promise.race([wp, f]);
// wp is pending and never settles
// done / f is rejected
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.
I opened a bug report in chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=1480250
Because I would expect that any fetch error would properly cancel the ReadableStream
(which the browser locks) and thus any writer promises would be rejected.
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpInterop.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
unfortunately the transform stream does not get notified when fetch fails or cancels so we need to race with it
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
afd05d7
to
f2a7f9d
Compare
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpInterop.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Outdated
Show resolved
Hide resolved
I guess the ball is on my side of the court now, I will do full review early next week. Sorry for delay. |
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs
Show resolved
Hide resolved
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsUses a Ref: #91295 (comment)
|
/azp run runtime-wasm |
Azure Pipelines successfully started running 1 pipeline(s). |
Uses a
TransformStream
into which theHttpContent
gets copied into. Sync writes are not allowed like sync reads in response streaming.Ref: #91295 (comment)