Closed
Description
Describe the bug
I'm encountering an issue with the Socket.IO Client (version 4.7.5) when using emitWithAck
in environments with unstable network connections.
When the client is disconnected and then reconnects (e.g., due to a brief backend outage), the event that was sent using emitWithAck
gets emitted multiple times — specifically, it is emitted once initially and then three more times (matching the number of retries configured).
This leads to the server receiving and processing the same event multiple times after reconnection.
Steps to reproduce
- Start the Socket.IO client with the configuration shown below.
- Emit an event using
emitWithAck
. - Pause the backend Docker container to simulate a network failure.
- Unpause the container to simulate reconnection.
- Observe that the event is emitted multiple times after reconnection.
Client configuration
{
ackTimeout: 1000,
retries: 3,
// Manager options
autoConnect: true,
reconnection: true,
reconnectionAttempts: 100,
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
timeout: 20000,
addTrailingSlash: true,
transports: ["websocket", "polling"],
upgrade: true,
withCredentials: true
}