WebSocket: apply a write high-water mark, as #7487 did for TCP
Author: MajorBreakfastCreated Sep 28, 2026Updated Sep 28, 2026
Labelsenhancement
What is the problem this feature would solve?
A client that reads slowly makes the server hold everything sent to it. fromWebSocket's write calls ws.send(chunk) and succeeds at once, so nothing bounds that:
Workaround: I, or rather Claude :D, had to reach into ws through its private kWebSocket symbol to use ws.send's callback.
What is the feature you are proposing to solve the problem?
write hands the message to ws, then waits while the unsent bytes are past a writeHighWaterMark, as TCP writes wait for 'drain' since #7487. A message counts from ws.send until its callback.
The mark would come from an option or a context reference. request.upgrade takes no options, so a server-side socket needs the reference.
What alternatives have you considered?
- A non-blocking mark:
hasRoomanddrainedon theWriter. - A
writethat completes once written, leaving the counting to every caller.
Source: Effect-TS/effect