Skip to content

fix(build): make native ABI switching interruption-safe#446

Open
AmagiDDmxh wants to merge 1 commit into
paperboytm:mainfrom
AmagiDDmxh:feat/native-runtime-dx
Open

fix(build): make native ABI switching interruption-safe#446
AmagiDDmxh wants to merge 1 commit into
paperboytm:mainfrom
AmagiDDmxh:feat/native-runtime-dx

Conversation

@AmagiDDmxh

Copy link
Copy Markdown
Contributor

Why

Spool keeps one installed better-sqlite3 binary and switches it between the Node and Electron ABIs. Two parts of that workflow were costly or fragile:

  • The root pretest rebuilt the Node addon unconditionally, even when the installed binary already matched the current Node ABI.
  • with-electron-native.mjs used synchronous child processes, so an interrupt could terminate the wrapper before its Node-ABI restoration completed.

What changed

  • Probe better-sqlite3 with a real in-memory query before rebuilding for Node; rebuild only when the load/query fails.
  • Run the Electron rebuild, wrapped command, and Node restoration asynchronously.
  • Forward SIGHUP, SIGINT, and SIGTERM to the active child while keeping the wrapper alive long enough to restore the Node ABI.
  • Preserve signal-style exit codes after restoration.
  • Remove obsolete npm runtime/target environment overrides from the Node rebuild.
  • Update contributor and development documentation to match the managed ABI workflow.

Verification

  • A matching Node ABI took 1.91 seconds through pnpm run ensure:native:node and skipped compilation.
  • A real Electron-ABI switch followed by Ctrl-C completed the Node rebuild; better-sqlite3 then loaded successfully under Node ABI 137 and executed an in-memory query.
  • Both scripts passed node --check and focused Oxlint.
  • Workspace typecheck, type-aware lint, core tests (417 passed, 1 skipped), and app tests (450 passed) completed successfully.
  • The full local pnpm check reached the CLI suite, where 56/60 tests passed; four multi-process pin/unpin tests exceeded their existing 5-second timeout on this host. No timeout was changed or relaxed; PR CI remains the confirmation for those tests.

@AmagiDDmxh
AmagiDDmxh force-pushed the feat/native-runtime-dx branch from 82cdf9a to 58b403d Compare July 15, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant