MaxListenersExceededWarning when subscribing to worker’s observable: how to get an EventEmitter and setMaxListeners() on it?
- Dominant language
- TypeScript
- Stars
- 3.5k
- Forks
- 173
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.