pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.23k stars 199 forks source link

When queue is full, throw error instead of silently dropping messages #147

Open Gjum opened 3 years ago

Gjum commented 3 years ago

Currently the send method silently drops messages when the _messageQueue exceeds maxEnqueuedMessages.

Since this library is about automatically reconnecting and resending messages, the send method contract implies that messages aren't dropped while the client is disconnected.

As this method contract cannot be met when the queue is full, an exception should be thrown to signal this to the caller.

DanHarman commented 3 years ago

Yes it should have the standard websocket semantics of throwing connection not open when the queue is full. This would actually be useful since not all scenarios want to buffer sends over reconnects (e.g. pub sub requests, I hit a problem where the unsubscribe was buffered and sent on a new session which then caused problems with the ack message unsubscribing the new sub as the id counter reset).