-
Notifications
You must be signed in to change notification settings - Fork 161
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
Access to reader.readIntoRequests without checking reader type #686
Comments
@tyoshino would you be able to take a look at this? |
Hi @rombel, I'm sorry for the delay. Could you produce a bit of test code that you think might trigger this code path, i.e. a situation where ReadableByteStreamControllerRespondInClosedState is called, but the reader is a non-BYOB reader? |
Hi @domenic, no problem for the delay. If I understand the spec correctly, below sample leads to calling ReadableByteStreamControllerRespondInClosedState with a default reader. // First create a ReadableStream with a ReadableByteStreamController
// and a specific value for autoAllocateChunkSize.
let controller;
const rs = new ReadableStream({
autoAllocateChunkSize: 128,
start: function(c) {
controller = c;
},
type: "bytes"
});
// As autoAllocateChunkSize is defined, calling read() leads to adding
// an item to controller.pendingPullIntos through controller pull() method.
rs.getReader().read();
// Hence, byobRequest can be obtained (step 2 of "get byobRequest").
const br = controller.byobRequest;
controller.close();
// Stream has been closed prior to calling respond() and bytesWritten value
// is 0: therefore, ReadableByteStreamControllerRespondInClosedState is called.
br.respond(0); |
Thanks, I've confirmed this is indeed broken and am working on a fix! |
In particular, when autoAllocateChunkSize is in play, there may be a default reader instead. Fixes #686.
In particular, when autoAllocateChunkSize is in play, there may be a default reader instead. Fixes #686.
In particular, when autoAllocateChunkSize is in play, there may be a default reader instead. Fixes #686.
Thanks! |
This test is from whatwg/streams#686 (comment). The corresponding spec fix is whatwg/streams#698.
In particular, when autoAllocateChunkSize is in play, there may be a default reader instead. Fixes #686.
This test is from whatwg/streams#686 (comment). The corresponding spec fix is whatwg/streams#698.
Thanks rombel. Right. The purpose of the loop is to process all the entries. As I said at #698 (comment), we need to review all the logic to make sure this functionality is correctly handled everywhere. |
In particular, when autoAllocateChunkSize is in play, there may be a default reader instead. Fixes #686.
In particular, when autoAllocateChunkSize is in play, there may be a default reader instead. Fixes #686.
https://bugs.webkit.org/show_bug.cgi?id=172288 Patch by Romain Bellessort <romain.bellessort@crf.canon.fr> on 2017-05-23 Reviewed by Chris Dumez. Two changes are implemented in this patch: - Change #1: An issue was reported to GH [1] while working on respondInClosedState implementation. This issue has now been fixed, and this patch aligns implementation with spec [2]. - Change #2: In addition, this patch also fixes a bug that went unnoticed as code is not yet reachable (usage of controller.@reader is not valid and is therefore replaced by controller.@controlledReadableStream.@reader). [1] whatwg/streams#686 [2] https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond-in-closed-state No added test as: - Change #1 does not change behavior; - Change #2 is not testable as the code is not yet reachable. * Modules/streams/ReadableByteStreamInternals.js: (readableByteStreamControllerRespondInClosedState): Aligned with spec. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@217279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=172288 Patch by Romain Bellessort <romain.bellessort@crf.canon.fr> on 2017-05-23 Reviewed by Chris Dumez. Two changes are implemented in this patch: - Change #1: An issue was reported to GH [1] while working on respondInClosedState implementation. This issue has now been fixed, and this patch aligns implementation with spec [2]. - Change #2: In addition, this patch also fixes a bug that went unnoticed as code is not yet reachable (usage of controller.@reader is not valid and is therefore replaced by controller.@controlledReadableStream.@reader). [1] whatwg/streams#686 [2] https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond-in-closed-state No added test as: - Change #1 does not change behavior; - Change #2 is not testable as the code is not yet reachable. * Modules/streams/ReadableByteStreamInternals.js: (readableByteStreamControllerRespondInClosedState): Aligned with spec. Canonical link: https://commits.webkit.org/189402@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
In ReadableByteStreamControllerRespondInClosedState [1], ReadableStreamGetNumReadIntoRequests is called and checks reader.readIntoRequests, but it is not checked that the reader is a BYOBReader.
This could be checked based on firstDescriptor.readerType, but the purpose of the loop (step 4) may be the processing of all pendingPullIntos objects, in which case I'm not sure the test that involves the number of readIntoRequests is the right one (I may not get all the context here).
[1] https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond-in-closed-state
The text was updated successfully, but these errors were encountered: