Skip to content

Commit

Permalink
fix: limit WebSocket message backlog on reconnection 3.4 backport (#5489
Browse files Browse the repository at this point in the history
)

Signed-off-by: Peter Makowski <[email protected]>
  • Loading branch information
petermakowski authored Jun 26, 2024
1 parent c114c26 commit 9cbb8e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/websocket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9cbb8e3

Please sign in to comment.