Skip to content

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

Merged
codebytere merged 1 commit into42-x-yfrom
trop/42-x-y-bp-fix-prefer-browser-runtime-over-node-in-devtools-hostruntime-detection-1773653392107
Mar 16, 2026
Merged

fix: prefer browser runtime over node in DevTools HostRuntime detection#50274
codebytere merged 1 commit into42-x-yfrom
trop/42-x-y-bp-fix-prefer-browser-runtime-over-node-in-devtools-hostruntime-detection-1773653392107

Conversation

@trop
Copy link
Copy Markdown
Contributor

@trop trop bot commented Mar 16, 2026

Backport of #50241

See that PR for details.

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.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
@trop trop bot requested a review from a team as a code owner March 16, 2026 09:30
@trop trop bot requested review from a team and codebytere March 16, 2026 09:30
@trop trop bot added 42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Mar 16, 2026
@codebytere codebytere merged commit 270c9e7 into 42-x-y Mar 16, 2026
119 of 121 checks passed
@codebytere codebytere deleted the trop/42-x-y-bp-fix-prefer-browser-runtime-over-node-in-devtools-hostruntime-detection-1773653392107 branch March 16, 2026 13:41
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant