-
Notifications
You must be signed in to change notification settings - Fork 160
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
Discard auto-allocated BYOB request on enqueue #1171
Discard auto-allocated BYOB request on enqueue #1171
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.
lgtm
index.bs
Outdated
@@ -3136,6 +3136,13 @@ The following abstract operations support the implementation of the | |||
[$TransferArrayBuffer$](|firstPendingPullInto|'s [=pull-into descriptor/buffer=]). | |||
1. Perform ! [$ReadableByteStreamControllerInvalidateBYOBRequest$](|controller|). | |||
1. If ! [$ReadableStreamHasDefaultReader$](|stream|) is true | |||
1. If |controller|.[=ReadableByteStreamController/[[pendingPullIntos]]=] is not | |||
[=list/is empty|empty=], | |||
1. Assert: |controller|.[=ReadableByteStreamController/[[pendingPullIntos]]=]'s [=list/size=] |
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 had to think about this for a while to understand why it was true. Could you perhaps add a note explaining it?
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.
Hang on... this is wrong. Every call to ReadableStreamDefaultReader.read()
creates a new pull-into descriptor, regardless of whether we can pull()
again. For example, this creates two such descriptors:
let controller;
const stream = new ReadableStream({
start(c) {
controller = c;
},
type: 'bytes',
autoAllocateChunkSize: 16
}, {
highWaterMark: 0
});
const reader = stream.getReader();
const read1 = reader.read();
const read2 = reader.read();
What is true is that, if autoAllocateChunkSize
is not undefined, then the length of [[pendingPullIntos]]
matches that of [[readRequests]]
. So we need to remove only the first descriptor on enqueue()
.
Chrome is interested in this (I'm in the middle of implementing it). |
Implementation bug for Chrome: https://crbug.com/1257465. |
Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0
Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0
Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211027 Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/main@{#929119}
Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211027 Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/main@{#929119}
Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211027 Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/main@{#929119}
There *can* be more than one auto-allocated pull-into descriptor.
@ricea I'm afraid you're going to have to re-open that Chromium bug. We assumed that there'd only be one auto-allocated pull-into descriptor, but that's not correct. |
Thanks for looking at it again! I am updating the fix in Chromium. |
Tests are merged so you can roll them and then we can merge this PR. Can you also file a WebKit bug? They appear to have a BYOB stream implementation on their main branch, at least. Firefox is still missing byte stream support. |
Implementation bugs filed. Do we need to ask for implementer interest from the WebKit folks? Since this is more of a bug fix, I guess it's not that critical. |
Yeah, for a bug fix I'm OK just merging as-is. |
…eue(), a=testonly Automatic update from web-platform-tests ReadableStream: Fix respond() after enqueue() Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211027 Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/main@{#929119} -- wpt-commits: 73ff424533dc6b1277ab978b3be72cafebf7299c wpt-pr: 31145
…eue(), a=testonly Automatic update from web-platform-tests ReadableStream: Fix respond() after enqueue() Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211027 Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/main@{#929119} -- wpt-commits: 73ff424533dc6b1277ab978b3be72cafebf7299c wpt-pr: 31145
Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211027 Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/main@{#929119}
Calling respond() after enqueue() on a readable byte stream when autoAllocateChunkSize was in use would cause a crash. Fix it by applying the change from whatwg/streams#1171. Fixed: 1255762,1257465 Change-Id: Ic770e79878fb9f6363e55f8104ec0bacab0e60c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211027 Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/main@{#929119} NOKEYCHECK=True GitOrigin-RevId: 55317e09879898c8f6d2e1c010f5b567dd4d474c
As discovered in #1170 (comment): if a BYOB request was auto-allocated, but then you call
controller.enqueue()
instead ofbyobRequest.respond()
, then the auto-allocated pull-into descriptor stays in the queue. If you later on switch from a default reader to a BYOB reader, you run into trouble because the list of read-into requests no longer matches up with the list of pending pull-into descriptors.This PR fixes it by making
enqueue()
discard that auto-allocated BYOB request.@ricea
)(See WHATWG Working Mode: Changes for more details.)
Preview | Diff