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

Fix the internal IPC to only subscribe to events once #180

Merged
merged 7 commits into from
Apr 7, 2021
Merged

Fix the internal IPC to only subscribe to events once #180

merged 7 commits into from
Apr 7, 2021

Conversation

rroessler
Copy link
Contributor

On each construction of an ElectronStore instance, the initDataListener method is called. This causes duplicate ipcMain handlers for the 'electron-store-get-data' channel. Found that this causes an Electron EventEmitter warning of 'MaxListenersExceededWarning'. By setting an initialiser flag, events are handled as needed and does not cause this warning. Additionally if someone were to properly exceed this (in my case I was at 11), by dynamically creating larger amounts of stores (which could be possible in larger scale applications, although not recommended), this could have dangerous and odd side-effects.

On each construction of an ElectronStore instance, the initDataListener method is called. This causes duplicate ipcMain handlers for the 'electron-store-get-data' channel. Found that this causes an Electron EventEmitter warning of 'MaxListenersExceededWarning'. By setting an initialiser flag, events are handled as needed and does not cause this warning. Additionally if someone were to properly exceed this (in my case I was at 11), by dynamically creating larger amounts of stores (which could be possible in larger scale applications, although not recommended), this could have dangerous and odd side-effects.
index.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Re #180 (comment), you did not correctly copy the name I wrote.

index.js Outdated Show resolved Hide resolved
rroessler and others added 2 commits April 7, 2021 15:35
Making sure to AmericaniZe myself.

Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Original change was not fully American, needed to add some more Bald Eagles.
@sindresorhus sindresorhus changed the title Flagging Initialisation Data Listener Fix the internal IPC to only subscribe to events once Apr 7, 2021
@sindresorhus sindresorhus merged commit cbe1449 into sindresorhus:main Apr 7, 2021
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.

2 participants