Skip to content

Issue with emitWithAck #5334

Closed
Closed
@abdou6666

Description

@abdou6666

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

  1. Start the Socket.IO client with the configuration shown below.
  2. Emit an event using emitWithAck.
  3. Pause the backend Docker container to simulate a network failure.
  4. Unpause the container to simulate reconnection.
  5. 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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    to triageWaiting to be triaged by a member of the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions