fix: exclude Electron renderer from IN_NODE detection#951
Open
claygeo wants to merge 1 commit intoelectric-sql:mainfrom
Open
fix: exclude Electron renderer from IN_NODE detection#951claygeo wants to merge 1 commit intoelectric-sql:mainfrom
claygeo wants to merge 1 commit intoelectric-sql:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
IN_NODEis currently defined as:Electron exposes a full Node.js
processobject in renderer processes, includingprocess.versions.nodeas a string. This causesIN_NODEto evaluatetruein 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.electronguard:In Electron,
process.versions.electronis a version string (e.g."27.0.0"), which is truthy, so!process.versions.electronisfalse. In a real Node.js process,process.versions.electronisundefined, so the guard passes.This is a purely additive one-line change with no effect on any non-Electron environment.