← Back to release summary

WebSocketStream

Category
Network / Connectivity
Type
New or changed feature
Status
Enabled by default (Chrome 124)
Intent stage
Start prototyping

Summary

The WebSocket API provides a JavaScript interface to the RFC6455 WebSocket protocol. While it has served well, it is awkward from an ergonomics perspective and is missing the important feature of backpressure. The intent of the WebSocketStream API is to resolve these deficiencies by integrating WHATWG Streams with the WebSocket API.

Motivation

Currently applying backpressure to received messages is not possible with the WebSocket API. When messages arrive faster than the page can handle them, the render process will either fill up memory buffering those messages, become unresponsive due to 100% CPU usage, or both. Applying backpressure to sent messages is possible but involves polling the bufferedAmount property which is inefficient and unergonomic.

Standards & signals

Docs: https://web.dev/websocketstream/

Samples: https://github.com/ricea/websocketstream-explainer/blob/master/README.md

Explainers: https://github.com/ricea/websocketstream-explainer/blob/master/README.md https://docs.google.com/document/d/1XuxEshh5VYBYm1qRVKordTamCOsR-uGQBCYFcHXP4L0/edit

View on chromestatus.com