Unnecessary on("error") handlers

Aperta
#538 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
redis, typescript

Direzione di ricerca

Start in lib/index.ts around line 193, where the Redis client error handler is added during adapter construction. Inspect how existing error listeners are detected and verify the behavior when multiple namespaces share a client. Done means repeated namespace creation no longer adds unnecessary handlers or triggers MaxListenersExceededWarning while the missing-handler warning remains appropriate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The adapter constructor always adds an error to the redis clients here: https://github.com/socketio/socket.io-redis-adapter/blob/cdb55353f83c78cabe9788683e4dd93ac4cd50c9/lib/index.ts#L193

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?

Lingua principale
TypeScript
Stelle
2.8k
Fork
485
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di socketio/socket.io-redis-adapter

Tutte le issue di socketio/socket.io-redis-adapter

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.