Fix #1734: [Bug] better-sqlite3 native module ABI mismatch breaks plugin on Node 25#1818
Open
Memtensor-AI wants to merge 1 commit into
Open
Fix #1734: [Bug] better-sqlite3 native module ABI mismatch breaks plugin on Node 25#1818Memtensor-AI wants to merge 1 commit into
Memtensor-AI wants to merge 1 commit into
Conversation
… binary (#1734) When the OpenClaw Gateway runs under a different Node.js major version than the one used at `npm install` time (e.g. Homebrew Node 25 Gateway vs. nvm Node 22 install), `npm rebuild better-sqlite3` resolved via PATH could pick up yet another Node binary and recompile the addon against the wrong NODE_MODULE_VERSION — leaving the same ABI mismatch the rebuild was supposed to fix. Implements Issue #1734 Option A: drive every rebuild from `process.execPath` so the binding always targets the ABI of the runtime that will load it. - Add `src/storage/rebuild-native.ts` with `buildRebuildEnv` / `rebuildBetterSqlite3` helpers that pin `npm_node_execpath`, `NODE`, and prepend `dirname(process.execPath)` to `PATH` when spawning `npm rebuild`. - `index.ts` runtime auto-rebuild now uses the helper and reports the specific failure reason (`abi-mismatch` vs `load-error` vs `missing`), with operator-facing messages spelling out the pinned Node binary. - `src/storage/ensure-binding.ts` uses the same helper for its fallback. - `scripts/postinstall.cjs` applies the same pinning when it shells out to `npm install` / `npm rebuild`, so the two install entry points stay consistent. - Add `tests/rebuild-native.test.ts` (9 cases) covering the env layout and spawn-call shape, with injectable `spawnSync` so the unit tests don't touch real npm.
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.
Description
已修复 Issue #1734:memos-local-openclaw 插件现在使用 process.execPath 强制 npm rebuild 走 Gateway 当前 Node 二进制,彻底避免 PATH 上的 npm 误用其他 Node 版本导致的 NODE_MODULE_VERSION ABI 不匹配。新增 9 个单元测试,全部通过。
Related Issue (Required): Fixes #1734
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Not run; documentation-only change.
Checklist
@CarltonXiang, @syzsunshine219 please review this PR.
Reviewer Checklist