websockets
websockets copied to clipboard
WebSocket - enable backpressure support by supporting Streams integration
Filed from TAG review of WebSocket in HTML spec: w3ctag/design-reviews#268
WebSockets predate Streams in the platform, but there's no reason why support for Streams can't be grafted into WebSockets! The primary motivations to add Stream support is to enable convenient backpressure management for applications.
Lack of backpressure is unfortunate. If you can't keep up with the network you run out of CPU or RAM.
Such integration would need to rationalize how the onmessage event would be impacted.
@ricea
We've been looking at this for Chrome. Our tentative plan is to create a new API called WebSocketStream. This avoids confusion over what should happen if you use the new streaming API and the old event-based API at the same time. It also lets us fix the "default binaryType is blob" issue.
If that ends up being a thing, perhaps we should take that as an opportunity to create websocket.spec.whatwg.org and move the current API and https://fetch.spec.whatwg.org/#websocket-protocol there, as well as this new API.
See https://github.com/w3ctag/design-reviews/issues/394.