Fix Node.js native library lookup in packaged Electron apps#797
Fix Node.js native library lookup in packaged Electron apps#797Andrey1994 wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 825105c228
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const libPathCandidates = [ | ||
| defaultLibPath, | ||
| ...searchRoots.flatMap((root) => [ |
There was a problem hiding this comment.
Prioritize unpacked lib paths over app.asar paths
resolveLibPath() checks defaultLibPath first, so in Electron builds that use app.asar.unpacked it can still return an .../app.asar/... path when fs.existsSync reports that virtual ASAR entry as present. koffi.load/native dlopen requires a real filesystem path, so this selection causes native library loading to fail even when the unpacked copy exists; the unpacked candidates need to be searched before the default ASAR path.
Useful? React with 👍 / 👎.
Motivation
__dirname/../brainflow/lib, which does not resolve insideapp.asar/packaged layouts.app.asar.unpackedandprocess.resourcesPath).Description
resolveLibPath()innodejs_package/brainflow/lib_path.tsthat builds candidate paths (including unpackedapp.asarand commonnode_moduleslocations) and returns the first existing path or the original default as a fallback.BoardShim,DataFilter, andMLModelwithresolveLibPath()innodejs_package/brainflow/board_shim.ts,nodejs_package/brainflow/data_filter.ts, andnodejs_package/brainflow/ml_model.ts.process.resourcesPathwhen present in Electron.Testing
cd nodejs_package && npm run buildand the TypeScript build completed successfully after adding theprocesscast. ✅cd nodejs_package && npm run lintand linting failed with many existing formatting issues unrelated to this change; the failure is due to pre-existing repository-wideprettierviolations and not introduced by this patch. ❌nodejs_package/brainflow/lib_path.tsand that the three loaders now callresolveLibPath()instead of using the hardcoded__dirnamepath.Codex Task