MaxListenersExceededWarning when subscribing to worker’s observable: how to get an EventEmitter and setMaxListeners() on it?
- Linguagem predominante
- TypeScript
- Estrelas
- 3.5k
- Forks
- 173
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
I’m tracking status of certain entities, on which worker operates, this way:
In the worker, I keep one global dictionary with a `Subject` instance per each entity, and when operations happen on that entity I call `entities.next(newStatus)`.
In host (Electorn’s main), I list all entities to keep track of, and run `worker.streamEntityStatus(entityID).subscribe(doSometingWithStatus)` once for each in the beginning. (Status is then relayed to the renderer, etc.)
Once the user adds the 11th entity, though, there’s that warning:
> (node:5294) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Worker]. Use emitter.setMaxListeners() to increase limit
The docs say:
> This limit can be changed for individual EventEmitter instances using the emitter.setMaxListeners(n) method.
I suppose observable hides an EventEmitter instance somewhere, and it could be possible to get to it and setMaxListeners on it according to the number of entities I am tracking?
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Avaliação
Esta issue ainda não foi avaliada.