`socket npm outdated --json` appends an error object after valid JSON when npm exits with code 1
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 65/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
- Área
- cli
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 336
- Forks
- 72
- Merge medio
- 8 h 18 min
- PR fusionados (30 d)
- 70
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de SocketDev/socket-cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
SocketDev/socket-cli#1655 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
SocketDev/socket-cli#1160 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
SocketDev/socket-cli#1525 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
SocketDev/socket-cli#1517 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
SocketDev/socket-cli#1498 ·
Los mantenedores suelen responder en 1 día
Todos los issues de SocketDev/socket-cli
Issues similares
-
category::task code priority::normal
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
e0ipso/strikethroo#145 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
cocos/cocos-docs#3333 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
RevenueCat/react-native-purchases#2079 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
RevenueCat/purchases-hybrid-common#2039 ·
Los mantenedores suelen responder en 1 día
-
agent-reported area/react bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día