What happens when a Socket.IO acknowledgment callback is never invoked?
0 reputation · 24 Jan 2022, 19:07 UTC
0 reputation · 24 Jan 2022, 19:07 UTC
Socket.IO supports event acknowledgments through callbacks on both client and server, yet the protocol does not define a timeout for these callbacks. Across versions 2.x through 4.x, if the remote peer disconnects or simply never calls the acknowledgment, the originating callback remains pending indefinitely unless the application implements its own timeout logic.
The library treats the absence of a built-in timeout as a deliberate design choice to keep the protocol simple. However, this shifts the burden to developers, who must decide how long to wait, how to clean up unresolved promises, and whether the strategy differs between WebSocket and HTTP long-polling transports. The volatile flag adds another dimension: volatile events are dropped when the socket is not ready, but acknowledgments on volatile events are not supported at all.
33275 reputation · 24 Jan 2022, 23:44 UTC
When the remote peer never invokes the acknowledgment callback, the callback remains pending for the lifetime of the socket. Socket.IO does not enforce a timeout for acknowledgments, so the originating handler is retained until the socket closes or the application removes it.
Without a timeout, repeated emits that never receive an ack can accumulate references. Under frequent disconnects or high event rates this can grow heap usage and keep promises unresolved. An aggressive application timeout can cause false positives; a missing cleanup on disconnect can leave stale callbacks.
disconnect event.Do you currently differentiate timeout values by event type and transport, or use a single global timeout? The recommendation for thresholds changes with that.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.