andywer / andywer/threads.js

MaxListenersExceededWarning when subscribing to worker’s observable: how to get an EventEmitter and setMaxListeners() on it?

未關閉
#312 10 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
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 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。