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 WebContentsView crash on app quit #191

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

kethinov
Copy link
Contributor

@kethinov kethinov commented Feb 6, 2025

If you do something like this in your Electron app:

const someWebView = new WebContentsView()
const ContextMenu = await import('electron-context-menu')
const contextMenu = ContextMenu.default
contextMenu({ window: someWebView })

The app will crash when you quit with an error like:

A JavaScript error occurred in the main process

Uncaught Exception:
TypeError: win.isDestroyed is not a function
at node_modules/electron-context-menu/index.js:353:11
at WebContents.disposable (node_modules/electron-context-menu/index.js:377:4)
at Object.onceWrapper (node:events:633:26)
at WebContents.emit (node:events:518:28)

This PR fixes that error.

@sindresorhus sindresorhus changed the title Fix WebContentsView crash on app quit Fix WebContentsView crash on app quit Feb 6, 2025
@sindresorhus sindresorhus merged commit 9fd50d8 into sindresorhus:main Feb 6, 2025
2 checks passed
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