From 9cbb8e3de32552934cfbd699f28af79de50739c1 Mon Sep 17 00:00:00 2001 From: Peter Makowski Date: Wed, 26 Jun 2024 13:59:27 +0200 Subject: [PATCH] fix: limit WebSocket message backlog on reconnection 3.4 backport (#5489) Signed-off-by: Peter Makowski --- src/websocket-client.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/websocket-client.ts b/src/websocket-client.ts index 74948a6f18..c669ad2a84 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -160,6 +160,10 @@ export class WebSocketClient { connect(): ReconnectingWebSocket { this.rws = new ReconnectingWebSocket(this.buildURL(), undefined, { debug: process.env.REACT_APP_WEBSOCKET_DEBUG === "true", + // Limit message backlog on reconnection to prevent overwhelming the server + // with a flood of queued messages when the connection is re-established. + // Typical page load generates 5-25 messages; buffer allows for additional user actions. + maxEnqueuedMessages: 30, }); return this.rws; }