`socket npm outdated --json` appends an error object after valid JSON when npm exits with code 1
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- cli
Research direction
Start by reading src/commands/npm/cmd-npm.mts (lines 95-119) and src/cli.mts (lines 53-99) to see how subprocess rejection reaches the top-level error handler. Reproduce with socket npm outdated -g --depth=0 --json using an outdated global package. Done means npm's valid JSON and exit status 1 are kept, with no extra error object appended.
Written by the indexing model from the issue text.
Description
Description
When global packages are outdated, socket npm outdated -g --depth=0 --json outputs npm’s valid JSON result, then appends a second JSON object reporting an unexpected error.
The combined stdout cannot be parsed as a single JSON document. npm intentionally returns exit code 1 when updates are available, so this status alone does not indicate an unexpected failure.
Environment
- Socket CLI: 1.8.4
- npm: 12.0.2
- Node.js: 24.18.0
- macOS: 27.0.1, Apple Silicon
Steps to reproduce
With at least one outdated global npm package, run:
socket npm outdated -g --depth=0 --json
In my environment, npm itself is outdated but intentionally held at its installed version.
Actual behavior
- Exit code:
1 - stdout: valid outdated-package JSON, followed by:
{
"ok": false,
"message": "Unexpected error",
"cause": "command failed"
}
- stderr: empty in the standalone reproduction.
This also reproduces outside the maintenance automation that first exposed it. Socket version/help checks and successful update commands work.
Expected behavior
Preserve npm’s JSON output and exit status without appending a generic error object for the expected “updates available” result.
Investigation
The npm wrapper both awaits spawnPromise and registers an exit handler that waits for telemetry before exiting. A rejected subprocess promise can reach the top-level error handler, which prints the additional JSON object.
This suggests an interaction between subprocess rejection and asynchronous exit handling; it is not a verified root-cause patch.
I compared tags v1.8.4 and v1.10.1. The relevant wrapper, subprocess launcher, telemetry and error-handler files are identical, with unchanged relevant dependency versions. However, the runtime reproduction is on 1.8.4; I have not executed 1.10.1.
For reference, npm 12.2.1 also explicitly sets exit code 1 when outdated packages exist.
- Dominant language
- TypeScript
- Stars
- 336
- Forks
- 72
- Avg merge
- 8h 18m
- Merged PRs (30d)
- 70
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SocketDev/socket-cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
SocketDev/socket-cli#1655 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SocketDev/socket-cli#1160 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
SocketDev/socket-cli#1525 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
SocketDev/socket-cli#1517 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
SocketDev/socket-cli#1498 ·
Maintainers usually reply within 1 day
All issues in SocketDev/socket-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
lichess-org/lila#22324 · 1 comment ·
Maintainers usually reply within 1 day
-
[Feature Request] [Web] Expose kvCacheQuantizationBits in the onnxruntime-web WebGPU EP optionsOpenep:WebGPU platform:web quantization
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
microsoft/onnxruntime#33752 ·
Maintainers usually reply within 2 days
-
[Skill Bug]: entra-agent-id: inaccurate blueprint permission inheritance and parent token sub claimOpenbug entra-agent-id
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/GitHub-Copilot-for-Azure#3467 · 1 comment ·
Maintainers usually reply within 1 day
-
fix(worker): keep normal prepare waiting states failure-freePossibly taken @LichKing-2234 claimed this today. Openagent:codex priority:P1
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AgoraIO-Extensions/agent-infra#3745 ·
Maintainers usually reply within 1 day
-
The five-line work window can drop its oldest line: the per-line byte share ignores the JSON framingPossibly taken @Eapp1e claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
makecindy/cindy#7973 · 1 comment ·
Maintainers usually reply within 1 day