Skip to content
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

Should ReadableStreams with pull sources call pull until full? #469

Closed
jplaisted opened this issue Jun 22, 2016 · 2 comments
Closed

Should ReadableStreams with pull sources call pull until full? #469

jplaisted opened this issue Jun 22, 2016 · 2 comments

Comments

@jplaisted
Copy link

Quick question, there's probably already been a consensus on this but it looks like ReadableStreams with pull sources do not call pull until full, at least with the default controller.

IE given a high water mark of 3 chunks and a pull source a ReadableStream will only call pull once rather than three times, assuming no read requests.

I assume the internal queues are meant to act as buffers. So shouldn't a ReadableStream attempt to fill its buffer? Simple solution seems to be to get rid of the pullAgain variable and just always call callPullIfNeeded after a successful pull.

@domenic
Copy link
Member

domenic commented Jun 23, 2016

Pull is called three times in your example. You can run the following code in Chrome Canary (or with the reference implementation) to confirm:

let counter = 0;
const rs = new ReadableStream({
    pull(c) {
        c.enqueue("a");
        console.log(`pull called ${++counter} times`);
    }
}, {
    highWaterMark: 3
});

This is tested in the web-platform-test general.js, "ReadableStream: should call pull after enqueueing from inside pull (with no read requests), if strategy allows".

Going to close since this doesn't appear to be an issue, but happy to continue discussing and will reopen if I missed something!

@domenic domenic closed this as completed Jun 23, 2016
@jplaisted
Copy link
Author

Yep my mistake. Reading through the spec I must have missed 3.9.5. step 6 (call pull again if needed after enqueue).

https://streams.spec.whatwg.org/#enqueue-in-readable-stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants