Re: [whatwg/streams] strategy.size() can reenter WritableStream logic before its caller finishes all the work (#675)

It looks like there's no assertion failures, although the chunks get enqueued in the reverse of the order in which `enqueue()`/`write()` was called, when there are recursive calls.

```js
var c;
var strategy = {
  size(chunk) {
    if (chunk >= 1)
      c.enqueue(chunk-1);
    return chunk;
  }
};

var rs = new ReadableStream({start(controller){c = controller;}}, strategy);

c.enqueue(5);
rs.getReader().read(); // earliest enqueued chunk is 0 instead of 5
```

```js
var writer;
var strategy = {
  size(chunk) {
    if (chunk >= 1)
      writer.write(chunk-1);
    return chunk;
  }
};

var ws = new WritableStream({write(chunk) {console.log(chunk);}}, strategy);
writer = ws.getWriter();
writer.write(5);
```

-- 
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/675#issuecomment-275280072

Received on Thursday, 26 January 2017 00:55:15 UTC