[whatwg/streams] Constructing a readable byte stream can reach code that assumes a default reader (#646)

Found by @tschneidereit:

- [new ReadableStreamDefaultController](https://streams.spec.whatwg.org/#rs-default-controller-constructor) step 11.a.iv. ->
- [ReadableStreamDefaultControllerCallPullIfNeeded](https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed) step 1 ->
- [ReadableStreamDefaultControllerShouldCallPull](https://streams.spec.whatwg.org/#readable-stream-default-controller-should-call-pull) step 5 ->
- [ReadableStreamGetNumReadRequests](https://streams.spec.whatwg.org/#readable-stream-get-num-read-requests) which assumes _stream_.[[reader]].[[readRequests]] exists, which is not true for byte readers.

Untested, but I think the repro code is then something like:

```js
const rs = new ReadableStream({ type: "bytes" });
const reader = rs.getReader();
```

@tschneidereit mentions that his Gecko implementation is failing the test "ReadableStream with byte source: autoAllocateChunkSize", whereas the reference implementation for some reason is not.

---

I think the correct fix here is to bail in ReadableStreamDefaultControllerCallPullIfNeeded immediately if the reader is not a default reader. @tyoshino, does that sound right? We should also track down the missing test coverage though.

-- 
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/streams/issues/646

Received on Wednesday, 11 January 2017 23:56:27 UTC