Skip to content

fix: exclude Electron renderer from IN_NODE detection#951

Open
claygeo wants to merge 1 commit intoelectric-sql:mainfrom
claygeo:fix/electron-in-node
Open

fix: exclude Electron renderer from IN_NODE detection#951
claygeo wants to merge 1 commit intoelectric-sql:mainfrom
claygeo:fix/electron-in-node

Conversation

@claygeo
Copy link
Copy Markdown

@claygeo claygeo commented Mar 30, 2026

Problem

IN_NODE is currently defined as:

export const IN_NODE =
  typeof process === 'object' &&
  typeof process.versions === 'object' &&
  typeof process.versions.node === 'string'

Electron exposes a full Node.js process object in renderer processes, including process.versions.node as a string. This causes IN_NODE to evaluate true in Electron renderers, which triggers the Node.js worker/filesystem code path instead of the browser WASM path — crashing the renderer.

Fixes #813

Fix

Add a !process.versions.electron guard:

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

In Electron, process.versions.electron is a version string (e.g. "27.0.0"), which is truthy, so !process.versions.electron is false. In a real Node.js process, process.versions.electron is undefined, so the guard passes.

This is a purely additive one-line change with no effect on any non-Electron environment.

Electron exposes a full Node.js process object, including
process.versions.node, which caused IN_NODE to evaluate true in
Electron renderer processes. This triggered the Node.js worker/fs
code path instead of the browser WASM path, crashing the renderer.

Add a !process.versions.electron guard so Electron renderers are
correctly treated as browser environments.

Fixes: electric-sql#813
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package does not work in electron due to current checks of IN_NODE

1 participant