Skip to content

Commit

Permalink
fix: limit WebSocket message backlog on reconnection 3.5 backport (#5490
Browse files Browse the repository at this point in the history
)
  • Loading branch information
petermakowski authored Jun 26, 2024
1 parent 43b362b commit 8c0b18f
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 @@ -162,6 +162,10 @@ export class WebSocketClient {
connect(): ReconnectingWebSocket {
this.rws = new ReconnectingWebSocket(this.buildURL(), undefined, {
debug: import.meta.env.VITE_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 8c0b18f

Please sign in to comment.