Re: [whatwg/streams] Fix makeReadableBackpressureByteSocketStream to drain all data (#504)

I was inspecting the code of the example itself. It made no effort to read more data if there was more than v.byteLength / DEFAULT_WINDOW_SIZE pending. If the example is correct, this means that onreadable must keep being fired as long as there is still data available.

It seems to me that Javascript events don't normally work that way. For one thing, if you're not ready to handle the data yet you'd have to actually unregister the event handler in order to stop the event loop from spinning. That seems unusual.

select() is also level-triggered, but it's not as problematic because
 a) It's a pull API, and
 b) It's idiomatic to remove descriptors from the set when you're not ready to read/write from them yet

Having said that, given the complexity of the fix, it may be simpler just to mention that onreadable is level-triggered and leave it at that.

---
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/pull/504#issuecomment-237765972

Received on Friday, 5 August 2016 06:23:45 UTC