MaxListenersExceededWarning when subscribing to worker’s observable: how to get an EventEmitter and setMaxListeners() on it?
- 主要语言
- TypeScript
- 星标
- 3.5k
- 派生
- 173
- PR 合并指标
- 30 天内没有已合并 PR
描述
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?
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。