-
-
Notifications
You must be signed in to change notification settings - Fork 156
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: object has been destroyed #183
Conversation
547032b
to
044fb00
Compare
To reproduce the issue in your example, use the following code in fixture.js that will destroy the window (async () => {
await app.whenReady();
const window = new BrowserWindow({
webPreferences: {
spellcheck: true,
},
});
await window.loadFile(path.join(import.meta.dirname, 'fixture.html'));
// wait 5seconds, destroy the window
setTimeout(() => {
window.destroy();
}, 5000);
})(); |
// @lovemegowin |
We can remove electron-context-menu/index.js Line 377 in 125230e
once .But it also will cause memory leak in multiple window case. Could you please do this remove ? @benoitf |
044fb00
to
43f4626
Compare
@lovemegowin I've amended the PR |
receive an error from webContents saying the object has been destroyed when executing the line win.webContents.off('destroyed', disposable); we can't unsubscribe once it's already destroyed Signed-off-by: Florent Benoit <fbenoit@redhat.com>
43f4626
to
7352ee1
Compare
I have reviewed the electron events, but didn't found a reasonable timing to do this cleanup yet. |
thanks @sindresorhus for the quick merge and the new release |
#182 added some changes in v4.0.2
but in our case, when closing the application there is now an error thrown by the code
A JavaScript error occurred in the main process
Uncaught Exception:
TypeError: Object has been destroyed
at WebContents.disposable (packages/main/dist/index.cjs:11962:12)
at Object.onceWrapper (node:events:634:26)
at WebContents.emit (node:events:519:28)
the related code is:
electron-context-menu/index.js
Line 377 in 125230e
we can't unsubscribe once it's already destroyed
trying to move the unsubscribe outside of the callback itself (I don't know if it was expected to have a self-reference callback)