Skip to content

fix(npm): preserve JSON output on nonzero exits - #1797

Merged
John-David Dalton (jdalton) merged 1 commit into
v1.xfrom
fix/1656-preserve-npm-output
Dec 2, 2026
Merged

John-David Dalton (jdalton) merged 1 commit into
v1.xfrom
fix/1656-preserve-npm-output

Conversation

@jdalton

@jdalton John-David Dalton (jdalton) commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

socket npm outdated --json now preserves npm’s JSON and exit code when updates are available. The wrapper forwards the child’s exit status after flushing telemetry and still reports failures to start npm.

Fixes #1656

@cursor

cursor Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Localized change to npm wrapper exit/telemetry sequencing with new tests; no auth or data-path changes.

Overview
The socket npm wrapper replaces the child-process exit event handler with a new awaitNpmSpawn helper that awaits the npm subprocess, flushes telemetry, then forwards the child's exit code or signal.

That fixes cases like socket npm outdated --json, where npm writes JSON and exits nonzero: the wrapper now waits for the child to finish before exiting, so stdout is preserved instead of being cut off. Launch failures (e.g. missing binary) still propagate as errors. Unit tests cover nonzero exits with JSON, signal termination, and ENOENT.

Reviewed by Cursor Bugbot for commit 0f10a65. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0f10a65. Configure here.

Comment thread src/commands/npm/cmd-npm.test.mts Resolved
@jdalton John-David Dalton (jdalton) changed the title Preserve npm JSON output on nonzero exits fix(npm): preserve JSON output on nonzero exits Dec 2, 2026
@jdalton
John-David Dalton (jdalton) force-pushed the fix/1656-preserve-npm-output branch 2 times, most recently from 5dd240f to 56ced70 Compare December 2, 2026 01:00
@jdalton
John-David Dalton (jdalton) merged commit f8b66a2 into v1.x Dec 2, 2026
23 checks passed
@jdalton
John-David Dalton (jdalton) deleted the fix/1656-preserve-npm-output branch December 2, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

socket npm outdated --json appends an error object after valid JSON when npm exits with code 1

2 participants