`socket npm outdated --json` appends an error object after valid JSON when npm exits with code 1
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 65/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- node.js, typescript
- Domínio
- cli
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 336
- Forks
- 72
- Merge médio
- 8h 18min
- PRs com merge (30d)
- 70
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de SocketDev/socket-cli
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
SocketDev/socket-cli#1655 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
SocketDev/socket-cli#1160 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
SocketDev/socket-cli#1525 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
SocketDev/socket-cli#1517 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
SocketDev/socket-cli#1498 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de SocketDev/socket-cli
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
vekexasia/pi-extensible-workflows#374 ·
Mantenedores costumam responder em até 2 dias
-
documentation good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
Mantenedores costumam responder em até 1 dia
-
help wanted linux
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
GiuseppeBellamacina/downtime#19 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
scaleway/ultraviolet#7089 ·
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Get-Concord-AI/concord-mcp#296 ·
Mantenedores costumam responder em até 1 dia