Description
Is your feature request related to a problem? Please describe.
Our app operates in some areas with poor internet connectivity, and network interruptions are quite common. When our client's call socket.emit
, often the underlaying websocket will close before the message reaches the server. Since the socket was connected at the time of the emit
, the messages aren't added to the this.sendBuffer
queue. So, effectively, they are lost. And the application code waits indefinitely for the ack callabck.
Describe the solution you'd like
I would like a feature similar to the timeout()
feature, but for transport close events.
When a "close" event is received on a transport, any remaining entries in this.acks
should be invoked with an Error, and removed. Since the transport is closed, there is no hope of an actual ack coming from the server. This should also prevent some memory leak issues, because this.acks
is holding references to functions for acks that will never come.
When the application receives the Error callback, it can decide if it wants to retry the emit, or to inform the user of the failure.
Describe alternatives you've considered
This functionality could probably be built into the application layer above socketio. But, it would fit more cleanly into the this.acks
datastructure. The application also doesn't have the ability to clean out the this.acks
data structure, which could lead to memory leaks.
Additional context
I'm happy to put together a PR for this.
Activity