chore(native): add pnpm check:native mismatch detection script - #248
Merged
Conversation
Adds a cross-platform Node script that detects NODE_MODULE_VERSION
mismatch between the built native modules (better-sqlite3, keytar)
and the current runtime (Node or Electron), and prints the correct
fix command.
- New: apps/desktop/scripts/check-native.js
- New: pnpm check:native in root package.json
Detection: spawns a child Node process that requires each native
module; on ERR_DLOPEN_FAILED, parses the compiled/expected ABI from
the error message. Reports the stamp file's last build target and
suggests pnpm rebuild:node or pnpm rebuild:electron as appropriate.
Example output (mismatch):
[check:native] NODE_MODULE_VERSION mismatch — 2 module(s) failed to load under node:
- better-sqlite3: compiled for ABI 141, runtime needs ABI 133
- keytar: compiled for ABI 141, runtime needs ABI 133
[check:native] stamp says last build target was "electron"; current runtime is "node".
[check:native] fix:
pnpm rebuild:node # to run tests/scripts under Node
pnpm rebuild:electron # to run the Electron app (pnpm dev)
Plan: .claude/plans/tech-debt-remediation.md § 6.1
h4yfans
added a commit
that referenced
this pull request
May 6, 2026
Adds a cross-platform Node script that detects NODE_MODULE_VERSION
mismatch between the built native modules (better-sqlite3, keytar)
and the current runtime (Node or Electron), and prints the correct
fix command.
- New: apps/desktop/scripts/check-native.js
- New: pnpm check:native in root package.json
Detection: spawns a child Node process that requires each native
module; on ERR_DLOPEN_FAILED, parses the compiled/expected ABI from
the error message. Reports the stamp file's last build target and
suggests pnpm rebuild:node or pnpm rebuild:electron as appropriate.
Example output (mismatch):
[check:native] NODE_MODULE_VERSION mismatch — 2 module(s) failed to load under node:
- better-sqlite3: compiled for ABI 141, runtime needs ABI 133
- keytar: compiled for ABI 141, runtime needs ABI 133
[check:native] stamp says last build target was "electron"; current runtime is "node".
[check:native] fix:
pnpm rebuild:node # to run tests/scripts under Node
pnpm rebuild:electron # to run the Electron app (pnpm dev)
Plan: .claude/plans/tech-debt-remediation.md § 6.1
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.
Part of Phase 6 Tech Debt Remediation — see
.claude/plans/tech-debt-remediation.md § 6.1.Summary
apps/desktop/scripts/check-native.js— cross-platform Node script that detects NODE_MODULE_VERSION mismatch by attempting torequire()each native module in a child process and parsing any ERR_DLOPEN_FAILED output.pnpm check:nativewired next to othercheck:*scripts.ensure-native.shto report last build target + suggest the rightpnpm rebuild:{node,electron}fix.Why
ERR_DLOPEN_FAILEDhas repeatedly burned cycles — per project memory, causedautoOpenLastVaultto silently fail and E2E tests to time out on.bn-container. Turning an opaque dlopen error into a one-command fix removes the landmine.Smoke test (run locally)
Test plan
pnpm typecheck && pnpm testgreen (no source touched)