From 493a618efc01d4964d15f0e52e2371d3ddd87456 Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Sat, 8 Aug 2026 17:26:59 +0300 Subject: [PATCH] perf(terminal): relax transport keepalive from 20s to 45s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ping has no pong-timeout on either side — it exists only to keep intermediaries from idling out the socket. 45s stays safely under the relay host-data idle reaper (90s) and common proxy read timeouts (60s), while halving the events that wake the relay Durable Object during an open session. --- packages/ui/src/lib/terminalApi.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/lib/terminalApi.ts b/packages/ui/src/lib/terminalApi.ts index 4bfce9d5..72e25849 100644 --- a/packages/ui/src/lib/terminalApi.ts +++ b/packages/ui/src/lib/terminalApi.ts @@ -343,7 +343,7 @@ export class TerminalTransport { this.idleCloseTimer = null; } - private startKeepalive(): void { this.stopKeepalive(); this.keepaliveTimer = setInterval(() => this.send({ t: 'ping', v: 3 }), 20_000); } + private startKeepalive(): void { this.stopKeepalive(); this.keepaliveTimer = setInterval(() => this.send({ t: 'ping', v: 3 }), 45_000); } private stopKeepalive(): void { if (this.keepaliveTimer) clearInterval(this.keepaliveTimer); this.keepaliveTimer = null; } private cancelReconnect(): void { if (this.reconnectTimer) clearTimeout(this.reconnectTimer); this.reconnectTimer = null; this.wakeCleanup?.(); this.wakeCleanup = null; } private closeSocket(): void { this.stopKeepalive(); const socket = this.socket; this.socket = null; if (socket && (socket.readyState === SOCKET_CONNECTING || socket.readyState === SOCKET_OPEN)) socket.close(); }