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

Unnecessary on("error") handlers #538

Open
KlausVii opened this issue Apr 17, 2024 · 0 comments
Open

Unnecessary on("error") handlers #538

KlausVii opened this issue Apr 17, 2024 · 0 comments

Comments

@KlausVii
Copy link

The adapter constructor always adds an error to the redis clients here:

this.pubClient.on("error", this.friendlyErrorHandler);

The handler just logs a warning if there are no other error handlers it

      if (this.listenerCount("error") === 1) {
        console.warn("missing 'error' handler on this Redis client");
      }

Since this constructor is called every time a namespace is created in socket io, we end up adding multiple copies of this handler to the underlying redis client possibly triggering a MaxListenersExceededWarning.

Would it be possible to add these handlers conditionally only if the client does not have any already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant