Skip to content

fix(npm): propagate native process termination signals - #76

Closed
DivyamTalwar wants to merge 2 commits into
hanzoai:mainfrom
DivyamTalwar:fix/npm-launcher-propagate-signal
Closed

DivyamTalwar wants to merge 2 commits into
hanzoai:mainfrom
DivyamTalwar:fix/npm-launcher-propagate-signal

Conversation

@DivyamTalwar

@DivyamTalwar DivyamTalwar commented Nov 22, 2026 •

Copy link
Copy Markdown

Problem

The npm launcher reports success when the native Hanzo process terminates from a signal. spawnSync returns status: null, which process.exit(r.status ?? 0) turns into a successful exit. That hides an interrupted command from scripts and CI.

Change

  • Propagate the native child's termination signal, consistent with npm/hanzo/bin/hanzo.js.
  • Treat a missing status as failure, not success.
  • Add isolated regressions for signals and ordinary nonzero exit codes; no downloads needed.

Verified

  • Reproduced before the patch: a SIGTERM-terminated fixture made the launcher exit 0.
  • node --test npm/install.test.js npm/launcher.test.js: 7 passed, 3 OS skips, 0 failed on macOS.
  • node --check npm/bin/hanzo.js, node --check npm/launcher.test.js, and git diff --check passed.

This is independent of open installer PR #9. No public API changes.

Independent-review follow-up (2026-11-23)

The npm release gate (make test) now executes all npm/*.test.js regressions. Node-reserved SIGUSR1 and ignored SIGPIPE no longer trigger inspector/incorrect termination behavior; all 3 targeted launcher tests passed. Combined reviewed npm changes: 20 passes, 0 failures, 3 platform skips on macOS.

@DivyamTalwar

Copy link
Copy Markdown
Author

@zeekay this and #77, #78, #79, #80, #81 and #82 are small, independent fixes to the npm launcher (signal propagation, archive cleanup, PATH checks, alias symlinks, argument handling, checksum and binary verification). Each one merges cleanly with main. The hanzo/ci check doesn't run on PRs from forks, so it needs a maintainer to trigger it. Ready for your review.

@DivyamTalwar

Copy link
Copy Markdown
Author

Cross-PR integration note: #76–#82 touch the npm launcher/installer and some shared test hunks. I reconstructed their combined changes with the independent-review fixes and ran node --test npm/*.test.js: 20 passed, 0 failed, 3 platform skips on macOS. This PR also updates the Makefile release gate to include the new test files. Later npm PRs may need normal conflict resolution/rebasing when the first lands; the full Rust/Windows/Linux release checks remain maintainer-CI work.

@zeekay

zeekay commented Nov 23, 2026

Copy link
Copy Markdown
Member

Thanks @DivyamTalwar, this is a really careful set of fixes, and the combined test run helps a lot. We're reviewing #76–#85 now, starting with the checksum (#81) and 401-replay (#84) fixes. We'll leave notes on each PR if anything needs rebasing.

zeekay added a commit that referenced this pull request Nov 25, 2026
…cher reliability (#92)

Consolidates #81, #79, #82, #77, #80, #78, and #76 into a single audited npm installer and launcher update:
- Security (#81): refuse empty or malformed .sha256 responses (require 64-hex SHA-256, normalize uppercase), and fail closed on invalid checksums for optional companions too.
- Security (#79): use lstatSync in linkAlias and unlink dangling symlinks before try/fallback so copyFileSync can never write through a stale symlink.
- Integrity (#82): extract standard tools in an isolated staging dir, reject missing/empty/directory/symlink placeholders, unlink existing destination entries before cpSync (preventing macOS cpSync abort on dangling symlinks and Linux ETXTBSY), preserve sidecar files, and keep prior installs intact on failure.
- Cleanup (#77): remove temporary downloaded archives in finally on all error paths.
- Reliability (#80): reject missing or flag-shaped values for -m/--model/-p/--port/--overlay in ENGINE_ADAPTER instead of infinite-looping; export ENGINE_ADAPTER.
- Reliability (#78): require regular executable files (not directories or non-executable files) on PATH in realBinary() and hasLocal(); isolate PATH in launcher-presence tests.
- Reliability (#76): propagate native child termination signals (mapping SIGUSR1/SIGPIPE to 128+sig instead of invoking Node inspector or ignoring SIGPIPE), treat missing status as 1, preserve 0755 mode on npm/bin/hanzo.js, and run all npm/*.test.js in Makefile test target.

Co-authored-by: Hanzo Dev <[email protected]>
@zeekay

zeekay commented Nov 25, 2026

Copy link
Copy Markdown
Member

Audited, hardened, and consolidated with #76–#82 into #92, merged into main at commit 6ae231d71c3377a700242ad810ee8153d1e9fdca (with full Co-authored-by attribution to @DivyamTalwar). Verified with node --test npm/*.test.js (23 passed, 0 failed, 3 platform skips under read-only HOME). Thank you!

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.

2 participants