Skip to content

webContentsView.webContents.isDevToolsOpened() crashes #47830

@powellnorma

Description

@powellnorma

Preflight Checklist

Electron Version

35.7

What operating system(s) are you using?

Ubuntu

Operating System Version

Ubuntu 24.04

What arch are you using?

x64

Last Known Working Electron version

No response

Does the issue also appear in Chromium / Google Chrome?

No

Actual Behavior

This code:

const webContents = this.webContentsView.webContents;

console.log("webContents.isDestroyed():", webContents.isDestroyed());
console.log("webContents.isDevToolsOpened()", webContents.isDevToolsOpened());

Results in:

webContents.isDestroyed(): false
<crash>

The original code was more like this: if (!webContents.isDestroyed() && webContents.isDevToolsOpened()) {..}, and crashes as well.

The underlying web Contents has likely called "window.close()".

Its called from an "blur" event listener:

webContentsView.webContents.on("blur", () => {..});

Expected Behavior

It should not crash..

Testcase Gist URL

https://gist.github.com/b797e4f192345ed19276e39a3bc72ac5

Additional Information

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions