Re: [whatwg/streams] "Set totalSize to totalSize + pair.[[size]]." (#582)

I would add 4), desiredSize is always <= HWM. That's not guaranteed by the proposed workaround:

```js
let controller;
const rs = new ReadableStream({ start(c) { controller = c; } },
  { size(item) { return item.size; }, highWaterMark: 1 }
);
const reader = rs.getReader();
sizes = [];
sizes.push(controller.desiredSize);
controller.enqueue({size: Number.MAX_VALUE});
sizes.push(controller.desiredSize);
controller.enqueue({size: 10});
sizes.push(controller.desiredSize);
reader.read();
sizes.push(controller.desiredSize);
reader.read();
sizes.push(controller.desiredSize);
console.log(sizes + '');
```

Ideally this would print `1,-1.7976931348623157e+308,-9,1`. In Chrome, SpiderMonkey, and the reference implementation it currently prints `1,-1.7976931348623157e+308,-1.7976931348623157e+308,1,11`.

What I'd propose is to instead change step 3 of `GetTotalQueueSize` to "Return max(_totalSize_, 0)". That still doesn't quite do the right thing - it prints `1,-1.7976931348623157e+308,-1.7976931348623157e+308,1,1` - , but it satisfies 4). The alternatives would be to use the currently specced behavior or to refresh the cached queue size if it becomes negative. Neither of these seem appealing to me, though the latter is at least feasible.

-- 
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/582#issuecomment-273798489

Received on Thursday, 19 January 2017 15:01:48 UTC