- From: James M Snell <notifications@github.com>
- Date: Wed, 14 Jan 2026 12:30:30 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/1362@github.com>
jasnell created an issue (whatwg/streams#1362)
### What is the issue with the Streams Standard?
Take the following example...
```js
const rs = new ReadableStream({
start(c) {
queueMicrotask(() => {
console.log('A:', c.desiredSize);
c.enqueue('a');
console.log('B', c.desiredSize); // We've enqueued.. why is desiredsize unchanged?
});
},
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());
```
Per the expected behavior of the queue and highWaterMark and desiredSize, what would you expect the value of `c.desiredSize` at position B? The answer is a bit surprising and all of the impls appear to agree... but the result is extremely counterintuitive...
```
A: 1
B 1
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 1
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 1
C 1
D 0
{
value: "a",
done: false,
}
{
value: "b",
done: false,
}
{
value: undefined,
done: true,
}
```
Chrome also agrees with `B 1`
If we run the same code outside of the `queueMicrotask`, directly within `start` without the deferral, we get the result I think is more expected, `B 0` ... but it seems that enqueing within the `queueMicrotask` in this example is possibly exposing a spec bug.
@annevk @MattiasBuelens ... any ideas here?
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1362
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/streams/issues/1362@github.com>
Received on Wednesday, 14 January 2026 20:30:34 UTC