Description
If remote is in use in the renderer and the page is reloaded >10 times (via location.reload()
or webContents.reload()
), the following scary sounding warning appears in the Node console:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 render-view-deleted listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
Took me a while to trace it to this package but I was able to isolate and confirm. Happens since at least Electron 15 all the way through latest v21, on Win and Mac. Basically if you run this code in a renderer 10 times:
console.log(require('@electron/remote').app.getPath('exe'));
location.reload();
the warning is thrown. Looks like merely doing require('@electron/remote')
alone won't trigger the warning but actually accessing any object through remote will. I wonder if there is some cleanup that's not being done on page reloads? I know the docs say to make sure to clean up interprocess references when using remote, but something as simple as require('@electron/remote').app.getPath('exe')
isn't even creating a persistent reference so I'm not sure what I could be doing wrong.