Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent memory leaks from .on() when register called multiple times #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

azmodii
Copy link

@azmodii azmodii commented Apr 17, 2021

In my current application, the user can select a download location. This can be updated many times in a single session. Due to being unable to update the path once a handler is registered, I have resorted to calling DownloadManager.register to update the path. The existing code causes multiple handlers to be registered when calling DownloadManager.register multiple times.

This causes the following output from node:

(node:3256) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 browser-window-created listeners added to [App]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:390:17)
    at App.addListener (events.js:406:10)
    ...

A more permanent solution would be an API to allow the update of the options parameter, but the module still should not cause this behaviour if used incorrectly. This PR fixes that behaviour.

In my current application, the user can select a download location. This can be updated many times in a single session. The existing code causes multiple handlers to be registered when calling DownloadManager.register.

This causes the following output from node:
```
(node:3256) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 browser-window-created listeners added to [App]. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:390:17)
    at App.addListener (events.js:406:10)
    ...
```

A more permanent solution would be an API to allow the update of the options parameter, but the module still should not cause this behaviour if used incorrectly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant