mirror of
https://github.com/electron/electron.git
synced 2026-03-19 03:02:02 -04:00
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: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>