Commit 7e0d6d1
authored
fix: detect Node via process.type to keep Electron main process working (#1033)
* fix: detect Node via process.type, not process.versions.electron
The Electron guard added in #951 (!process.versions.electron) also
disabled the Node code path in the Electron main and utility processes,
which are real Node environments that need it. process.versions.electron
is set in every Electron process, not just the renderer.
Key off process.type instead: exclude only Electron's web contexts
('renderer', 'worker', 'service-worker'), keeping the Node path for the
main ('browser') and utility processes, and for plain Node (no
process.type). Fixes the renderer crash from #813 without regressing
PGlite in the Electron main process.
Refs #951, #813
* refactor: extract isElectronWebContext helper, trim comment
Address review feedback on #1033: move the Electron/Node detection out of the
IN_NODE expression into a small named helper and trim the explanatory comment
from 9 lines to 3. Behavior is unchanged.1 parent 401137e commit 7e0d6d1
2 files changed
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
1 | 9 | | |
2 | 10 | | |
3 | 11 | | |
4 | 12 | | |
5 | | - | |
| 13 | + | |
6 | 14 | | |
7 | 15 | | |
8 | 16 | | |
| |||
0 commit comments