Skip to content

Fix WebContentsView crash on app quit#191

Merged
sindresorhus merged 2 commits intosindresorhus:mainfrom
kethinov:fix-WebContentsView-bug
Feb 6, 2025
Merged

Fix WebContentsView crash on app quit#191
sindresorhus merged 2 commits intosindresorhus:mainfrom
kethinov:fix-WebContentsView-bug

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