Re: [whatwg/fetch] Make response body streams readable byte streams (#1246)

> What I don't understand here is that you still get a fresh view if the BYOB view cannot be written into due to its size. Wouldn't an error or request for a new view be more appropriate? If the idea is to avoid allocations presumably you would not want such allocations to nevertheless happen silently sometimes?

Interesting. This is the first time we're hearing this feedback.

I'm not sure how these ideas would work. If you ask for a 1 KiB buffer, and Fetch is unable to restrict what it pulls from the network to less than 16 KiB, you'd get an error... and then what would you do? At that point Fetch has 16 KiB in memory in a new buffer. The only things we can do are:

- Give you the first 1 KiB of the 16 KiB buffer, and next time you ask give you (the requested portion of) the remaining 15 KiB; or
- Give you the entire 16 KiB buffer anyway.

The first option is more friendly toward people who are using BYOB readers to read specific numbers of bytes, e.g. when parsing a protocol, and so is what we chose.

I don't quite understand what you mean by "request for a new view" as opposed to error.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1246#issuecomment-882732642

Received on Monday, 19 July 2021 17:37:14 UTC