Skip to content

Commit

Permalink
fix: limit WebSocket message backlog on reconnection (#5487)
Browse files Browse the repository at this point in the history
- Update WebSocket reconnection logic to prevent overwhelming the server with a flood of queued messages when the connection is re-established.
  • Loading branch information
petermakowski authored Jun 26, 2024
1 parent 3040e2b commit f796cc5
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 f796cc5

Please sign in to comment.