[whatwg/streams] reader.read() inside strategy.size() doesn't work (#794)

If I understand correctly, the following test should pass:

```javascript
promise_test(() => {

  let controller;
  let readPromise;
  let reader;
  const rs = new ReadableStream({
    start(c) {
      controller = c;
    }
  }, {
    size() {
      readPromise = reader.read();
      return 1;
    }
  });
  reader = rs.getReader();
  controller.enqueue();
  return readPromise;

}, 'Readable stream: read() inside strategy size() should resolve');
```

In practice it times out.

I think the reason is that at step 3 of [ReadableStreamDefaultControllerEnqueue](https://streams.spec.whatwg.org/#readable-stream-default-controller-enqueue) it decides that since there isn't a read in process, the chunk should be queued. Then when `read()` is called inside `size()` the chunk isn't queued yet, so the read is queued in [ReadableStreamAddReadRequest](https://streams.spec.whatwg.org/#readable-stream-add-read-request) and remains pending.

Probably ReadableStreamDefaultControllerEnqueue should check  ReadableStreamGetNumReadRequests a second time.

Or maybe this is too weird to fix.

-- 
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/794

Received on Friday, 8 September 2017 11:14:12 UTC