Skip to content

fix: prefer browser runtime over node in DevTools HostRuntime detection#50241

Merged
codebytere merged 1 commit intomainfrom
fix-frontend-host-check
Mar 16, 2026
Merged

fix: prefer browser runtime over node in DevTools HostRuntime detection#50241
codebytere merged 1 commit intomainfrom
fix-frontend-host-check

Conversation

@codebytere
Copy link
Copy Markdown
Member

Description of Change

Closes #50220

Upstream DevTools' HostRuntime checks IS_NODE before IS_BROWSER when selecting the platform runtime. In Electron, process is available in renderer processes, so IS_NODE evaluates to true in the DevTools context. This causes DevTools to dynamically import the Node.js platform runtime, which uses node:worker_threads. DevTools Web Workers running under the devtools:// protocol cannot load Node.js built-in modules, so the import fails and breaks features like the formatter worker.

Fix by swapping the check order to prefer IS_BROWSER when both are true. This is safe because in pure Node.js environments (the only case where the node runtime is needed), window and self are both undefined, so IS_BROWSER is always false regardless of check order.

Upstreamed at https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7665878

Checklist

Release Notes

Notes: Fix an issue where some DevTools functionality didn't work as expected.

Upstream DevTools' HostRuntime checks `IS_NODE` before `IS_BROWSER` when
selecting the platform runtime. In Electron, `process` is available in
renderer processes, so `IS_NODE` evaluates to `true` in the DevTools
context. This causes DevTools to dynamically import the Node.js platform
runtime, which uses `node:worker_threads`. DevTools Web Workers running
under the `devtools://` protocol cannot load Node.js built-in modules,
so the import fails and breaks features like the formatter worker.

Fix by swapping the check order to prefer `IS_BROWSER` when both are
true. This is safe because in pure Node.js environments (the only case
where the node runtime is needed), `window` and `self` are both
undefined, so `IS_BROWSER` is always `false` regardless of check order.
@codebytere codebytere added the semver/patch backwards-compatible bug fixes label Mar 13, 2026
@codebytere codebytere requested a review from a team as a code owner March 13, 2026 09:03
@codebytere codebytere added target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. labels Mar 13, 2026
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 13, 2026
Copy link
Copy Markdown
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment, but was wondering if this would regression loading node entrypoints like devtools://devtools/bundled/js_app.html?v8only=true and realized this is more about the process hosting the devtools which shouldn't affect the app entrypoints.

LGTM

@github-actions github-actions bot added the target/42-x-y PR should also be added to the "42-x-y" branch. label Mar 13, 2026
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Mar 14, 2026
@codebytere codebytere merged commit cf84efb into main Mar 16, 2026
122 of 124 checks passed
@codebytere codebytere deleted the fix-frontend-host-check branch March 16, 2026 09:29
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Mar 16, 2026

Release Notes Persisted

Fix an issue where some DevTools functionality didn't work as expected.

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 16, 2026

I have automatically backported this PR to "42-x-y", please check out #50274

@trop trop bot added in-flight/42-x-y and removed target/42-x-y PR should also be added to the "42-x-y" branch. labels Mar 16, 2026
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 16, 2026

I have automatically backported this PR to "40-x-y", please check out #50275

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 16, 2026

I have automatically backported this PR to "41-x-y", please check out #50276

@trop trop bot added in-flight/40-x-y in-flight/41-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. and removed target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. in-flight/41-x-y in-flight/40-x-y in-flight/42-x-y labels Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some devtools feature are not working when opened in dedicated window

2 participants