Skip to content

MaxListenersExceededWarning due to SSUBSCRIBE/SUNSUBSCRIBE memory leak #528

Closed
@RoccoC

Description

@RoccoC

My project utilizes the ShardedRedisAdapter and Redis v7 to sync state across server instances. I am using the default "dynamic" subscription mode which creates a new channel subscription for each public room.

When a room is created, the new channel subscription is created and the adapter adds a listener to the client's smessageBuffer EventEmitter (by way of SSUBSCRIBE in /lib/util.ts). However, this event listener is not removed when the room is deleted, and consequently I'm encountering a MaxListenersExceededWarning when creating more than 8 rooms regardless of whether the rooms still exist.

I should increase the client's max listener threshold since it will not be uncommon to have >8 rooms at any given time, but it also looks like SUNSUBSCRIBE should be updated to remove the smessageBuffer listener. I'm happy to raise a PR to address this, but wanted to make sure I'm not missing something! Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions