Skip to content

Socket still fires event after disconnect #3095

Closed
@wagenaartje

Description

@wagenaartje

You want to:

  • report a bug

Current behaviour

I'm sending certain tasks to connected clients (all using Chrome), the clients then send back the result of the task. Of course, all tasks need to be completed and thus a task should be sent to another client when the first client disconnects.

So this is what is happening:

  • SERVER sends task to CLIENT
  • CLIENT disconnects (fires socket.on('disconnect', ...))
  • SERVER removes CLIENT from the task's client list and appoints task to new CLIENT2
  • CLIENT sends a message with task results (fires socket.on('completion', ...))

I have no idea how this is even possible. I have spent literally days trying to understand why the server would freeze and I just discovered this by doing the following:

  socket.on('completion', function (data) {
    console.log('Completing task...', socket.connected); // logs 'false'
    // do something
  });

Steps to reproduce (if the current behaviour is a bug)

I can't really give 'steps'. All I can say is that i'm sending tasks to the client that are finished within a second, and i'm sending 1000s of them sequentially. I should also mention that each client has X sockets doing tasks, one for every CPU core.

Expected behaviour

Should not fire an event when disconnected.

Setup

  • OS: Windows 10
  • browser: Chrome
  • socket.io version: latest

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions