Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/electron-main-process-in-node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@electric-sql/pglite': patch
---

Detect the Node environment via `process.type` instead of `process.versions.electron`. The previous Electron guard (#951) also treated the Electron main and utility processes as non-Node, which broke PGlite's filesystem code path there. `process.type` only excludes Electron's web contexts (renderer, web worker, service worker), so PGlite keeps using the Node.js path in the Electron main and utility processes. Follow-up to #951 / #813.
10 changes: 9 additions & 1 deletion packages/pglite-utils/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
// Electron exposes a Node-like `process` in its renderer/worker/service-worker
// contexts, which must use the browser fs path. Its main and utility processes
// are real Node environments (#813).
function isElectronWebContext(): boolean {
const type = (process as { type?: string }).type
return type === 'renderer' || type === 'worker' || type === 'service-worker'
}

export const IN_NODE =
typeof process === 'object' &&
typeof process.versions === 'object' &&
typeof process.versions.node === 'string' &&
!process.versions.electron
!isElectronWebContext()

export const WASM_PREFIX = '/pglite'

Expand Down
Loading