Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"emitWithAck" function leaks memory when acknowledgement timeout #4984

Open
ZhangSen1 opened this issue Mar 26, 2024 · 1 comment
Open

"emitWithAck" function leaks memory when acknowledgement timeout #4984

ZhangSen1 opened this issue Mar 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ZhangSen1
Copy link

Describe the bug

When using "emitWithAck" on the server side, the memory is not freed when the acknowledgement timeout is reached.

I tested on 500 client connections, and the memory usage is 1557MB after 3 hours.

Steps:

  1. Connect 500 clients, 10 clients per room, 50 rooms
  2. The first client in each room sends a message to the room every second(use emitWithAck)
  3. Each client does not call callback after receiving a message(simulation timeout)
  4. Memory usage is not freed

To Reproduce

Socket.IO server version: 4.7.2

Server

try{
    const responses = await socket.timeout(2000).to("room1").emitWithAck("event", "message");
} catch(err){

}

Socket.IO client version: 4.7.2

Client

 socket.on("event", (data, callback) => {
      // Do not call callback, simulation timeout.
      // callback(1);
    });

Expected behavior

Should not leak memory

Platform:

  • Server Node.js version: 18.18.0
  • Client Node.js version: 18.18.0
  • OS: win 10

Additional context

See broadcast-operator.ts timer, it seems that when timeout, ack function is not deleted from socket.acks.

@ZhangSen1 ZhangSen1 added the to triage Waiting to be triaged by a member of the team label Mar 26, 2024
@darrachequesne
Copy link
Member

Hi! I could indeed reproduce the issue, thanks for the detailed analysis 👍

Not sure how we can fix this though, let me check.

@darrachequesne darrachequesne added bug Something isn't working and removed to triage Waiting to be triaged by a member of the team labels Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants