-
Notifications
You must be signed in to change notification settings - Fork 166
Add an abstraction to pull from buffer into ReadableStream #1263
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
Conversation
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.
So one issue here is that this "buffer" type, and the operations on it, are undefined. The operations seem to be:
- "extracting from" which returns a byte sequence while presumably modifying the buffer;
- "size" which returns an integer; and
- "append" in fetch
I was OK with this as a one-off over in fetch, but since we're encountering this a couple times, we should think a bit harder about whether it's the route we want to go down. I.e., how should we represent underlying platform byte buffers in specs.
Options I can see:
- Leave it as-is in this PR. It's fine, probably people know what it means.
- Define a "platform byte buffer" type, probably in Streams, with a couple sentences describing what it generally corresponds to and explaining the two operations you can apply to one of these platform byte buffers.
- Use byte sequences instead. Then specs like Fetch would say something like "Let |buffer| be an empty [=byte sequence=]. NOTE: this represents the internal buffer inside the network layer of the user agent".
I think using byte sequences would be most reasonable. WDYT?
Co-authored-by: Domenic Denicola <[email protected]>
Good point! Using byte sequence sounds good to me. But we still have no definition for the operations, right? |
Well, yes, but we have length. And I feel less bad about using common-sense definitions if the base type is well-defined. So:
|
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.
Thanks, this algorithm looks great now! I pushed a commit to move it around and integrate it with the rest of that section; if those changes look good to you, then I think we can merge.
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.
LGTM, thanks for the cleanup!
index.bs
Outdated
@@ -6808,10 +6784,38 @@ They should only [=ArrayBufferView/create=] a new {{ArrayBufferView}} to pass to | |||
[=ReadableStream/enqueue=] when the [=ReadableStream/current BYOB request view=] is null, or when | |||
they have more bytes on hand than the [=ReadableStream/current BYOB request view=]'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.
Should we explicitly say the below algorithm doesn't enqueue "when they have more bytes on hand than ..."?
Also, w3c/webtransport#487 throws in that case, should it enqueue instead? Not sure it's fine to implicitly ignore the byob request view. Oh okay, it doesn't match what it wants in that case.
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.
Added a note, thanks!
Introduced in whatwg/streams#1263. Fixes #1610.
Intended to fix the Fetch spec issue whatwg/fetch#1610.
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff