Skip to content

Disconnection event not fired on manual disconnection #483

@ramiel

Description

@ramiel

Select which package(s) are affected

@livekit/rtc-node

Describe the bug

When disconnect function is called the event "Disconnected" is not fired. This happens because all listeners are removed but that event should be emitted before

Reproduction

const room = new Room();
room.on(RoomEvent.Disconnected, () => {
console.log('this is not called')
});

room.disconnect()

Logs

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 86.13 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
    pnpm: 9.15.5 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
    bun: 1.2.2 - ~/.bun/bin/bun
  npmPackages:
    @livekit/rtc-node: ^0.13.13 => 0.13.13

LiveKit server version

LiveKit cloud

Severity

serious, but I can work around it

Additional Information

No response

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