Skip to content

Commit 15c496e

Browse files
authored
fix(host): close a client socket at its backpressure limit instead of dropping frames (#446)
* fix(host): close a client socket at its backpressure limit instead of dropping frames Why: apps/host/src/gateway.ts#function websocket | gateway sockets must never drop a frame silently; past the backpressure limit they close so the client reconnects and re-watches * lane: sync stale-run memory
1 parent 8fbfcc3 commit 15c496e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
id: 01M50KBA3ME0Q9274A639MK6KJ
3+
anchor: function websocket
4+
created: 2026-10-15T20:16:37Z
5+
norm: '1'
6+
sig: 1b462e5d3bc33728
7+
body_hash: aee7bf28626367fb
8+
raw_hash: 6675f75b614405d9
9+
lines: 673-737
10+
---
11+
12+
gateway sockets must never drop a frame silently; past the backpressure limit they close so the client reconnects and re-watches

‎apps/host/src/gateway.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,11 @@ async function handle(
672672

673673
function websocket(): Bun.WebSocketHandler<Client> {
674674
return {
675+
// Past the limit Bun drops frames silently, and a watch that loses one, such as a run's end,
676+
// stays wrong; closing makes the client reconnect and re-watch. Screenshot-heavy chats replay
677+
// tens of megabytes to a renderer that reads slowly while it draws them.
678+
backpressureLimit: 128 * 1024 * 1024,
679+
closeOnBackpressureLimit: true,
675680
open(socket) {
676681
sockets.add(socket);
677682
log("info", "gateway.open", { user: socket.data.user, peer: socket.data.peer });

0 commit comments

Comments
 (0)