Re: [whatwg/streams] Interesting edge case... queueMicrotask and desiredSize in start algorithm (Issue #1362)

jasnell left a comment (whatwg/streams#1362)

In contrast... 

```js
const rs = new ReadableStream({
  start(c) {
    //queueMicrotask(() => {
      console.log('A:', c.desiredSize);
      c.enqueue('a');
      console.log('B', c.desiredSize);
    //});
  },
  pull(c) {
    console.log('C', c.desiredSize);
    c.enqueue('b');
    console.log('D', c.desiredSize);
    c.close();
  }
}, { highWaterMark: 1 });

const reader = rs.getReader();
console.log(await reader.read());
console.log(await reader.read());
console.log(await reader.read());
```

(with the microtask deferral commented out....

```
jsnell@james-cloudflare-build:~/projects/cloudflare/edgeworker/deps/workerd$ node ~/tmp/a.mjs
A: 1
B 0
C 1
D 0
{ value: 'a', done: false }
{ value: 'b', done: false }
{ value: undefined, done: true }
jsnell@james-cloudflare-build:~/projects/cloudflare/edgeworker/deps/workerd$ deno ~/tmp/a.mjs
A: 1
B 0
C 1
D 0
{ value: "a", done: false }
{ value: "b", done: false }
{ value: undefined, done: true }
jsnell@james-cloudflare-build:~/projects/cloudflare/edgeworker/deps/workerd$ bun run ~/tmp/a.mjs
A: 1
B 0
C 1
D 0
{
  value: "a",
  done: false,
}
{
  value: "b",
  done: false,
}
{
  value: undefined,
  done: true,
}
jsnell@james-cloudflare-build:~/projects/cloudflare/edgeworker/deps/workerd$ 
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1362#issuecomment-3751602446
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1362/3751602446@github.com>

Received on Wednesday, 14 January 2026 20:32:25 UTC