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

consider adding a note that response body may be re-buffered in browser #1573

Closed
wanderview opened this issue Mar 15, 2021 · 3 comments
Closed
Assignees

Comments

@wanderview
Copy link
Member

When a response is passed to respondWith() most (all?) browsers will end up serializing the body through some kind of data pipe with a fixed capacity. This means that a response constructed with a ReadableStream body may see the data chunks get re-buffered into different size chunks on the other side. It would be nice if the spec captured this in some way. Perhaps as a note if it can't really be represented in normative text.

Not sure if this should be here or in fetch. cc @annevk

@wanderview
Copy link
Member Author

For context, we got a bug from someone expecting that readablestream chunks would pass through in their original form:

https://bugs.chromium.org/p/chromium/issues/detail?id=1188114

@annevk
Copy link
Member

annevk commented Mar 15, 2021

When I wrote a comment in whatwg/fetch#267 (comment) in response to @ricea I did not expect it to already be a problem. 😊

I agree we should define this better. Ideally we'd also tackle the magic thread-boundary crossing at the same time.

cc @yutakahirano

(I think at least part of it should be here as the service worker needs to start this, but the infrastructure for it can be defined in Fetch and shared with the request side perhaps.)

@Banou26
Copy link

Banou26 commented Jan 30, 2022

Hey there,
I am the reporter for https://bugs.chromium.org/p/chromium/issues/detail?id=1188114

I was wondering if Transferable Streams (chrome support) could allow service workers to pass data directly to the target frame without getting re-buffered with a fixed size.

Passing a stream from a service worker to a webpage via transferable streams(using postMessage) actually do work as expected and send the entire, full sized buffer (in my test case, Uint8Array(1000000)).

So since the tech is already there(at least for chrome), i was wondering if it'd just be possible to use it for fetch's respondWith and get the correct behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants