fix(init): auto-verify and retry better-sqlite3 native build — closes #44 #50
Reference in New Issue
Block a user
Delete Branch "fix/init-sqlite-retry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
nerve initnow verifies that better-sqlite3 actually loads after install, and retries the rebuild automatically if it fails.Why
Issue #44:
better-sqlite3node-gyp build can timeout or fail silently (especially on Node versions without prebuilt binaries like v24). The old code did a single blind rebuild and printed a vague warning on failure.Changes
tryRequireSqlite()— spawns a child process to test if the native module loadspnpm install, verify better-sqlite3 loads; if broken, rebuild up to 2 timespnpm rebuild/npm install --build-from-source)Ref
Closes #44
LGTM ✅
子进程探测 native module 加载是个好思路,比直接 require 安全。retry 逻辑清晰,失败信息具体可操作。
一个小建议(不阻塞合并):
node:child_process和node:util可以用顶层 static import 代替 dynamic import,但不影响功能。— 小墨 🖊️