CLI: an indexer killed by a signal (out of memory) exits 1 with no message

Abierto Apto para principiantes
#3,277 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript, wasm
Área
backend, cli

Línea de trabajo

Empieza en src/extraction/wasm-runtime-flags.ts, especialmente en relaunchWithWasmRuntimeFlagsIfNeeded, e inspecciona cómo los resultados de spawnSync determinan el estado de salida de la CLI. Reproduce el caso en que el proceso hijo muere por una señal usando el comando con límite de memoria del issue y, después, revisa las pruebas existentes para esta ruta de relanzamiento. Se considera terminado cuando un proceso hijo terminado por una señal produce un mensaje en stderr que indique la señal y el código de salida esperado al estilo de la shell.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What happens

When the indexer that the CLI relaunches with the WASM runtime flags is killed by a signal, the codegraph command exits 1 and prints nothing. An out-of-memory kill during codegraph init or codegraph index then looks like an ordinary failure with no message, and the exit code doesn't say a signal was involved.

relaunchWithWasmRuntimeFlagsIfNeeded drops result.signal:

const result = spawnSync(process.execPath, argv, { stdio: 'inherit', ... });
if (result.error) { return; }
process.exit(result.status ?? (result.signal ? 1 : 0));

Repro (main f72c9d2e, Node 22.22.2, Linux x64 on WSL2, CODEGRAPH_KERNEL=0)

Any repo works if memory is capped low enough. With honojs/hono at f6fbaf0 and a 400 MB cgroup cap, where the kernel kills only the largest process:

systemd-run --user --scope -q -p MemoryMax=400M -p MemorySwapMax=0 -p OOMPolicy=continue \
  node --trace-exit dist/bin/codegraph.js init -i .
echo "exit=$?"
Scanning files...
Parsing code...
(node) WARNING: Exited the environment with code 1
    at exit (node:internal/process/per_thread:245:13)
    at relaunchWithWasmRuntimeFlagsIfNeeded (dist/extraction/wasm-runtime-flags.js:41:13)
    at dist/bin/codegraph.js:100:63
exit=1

Kernel log for the same run: Memory cgroup out of memory: Killed process … (node) … anon-rss:375764kB. Without --trace-exit, nothing is printed after Parsing code....

Control: the same command with CODEGRAPH_NO_RELAUNCH=1 exits 137, and the shell reports Killed.

The same thing happens without an artificial cap. Indexing microsoft/vscode at ca43fc94 under a 6 GiB limit exits 1 silently after Resolving refs... (child at 5.8 GB RSS when killed). Effect-TS/effect 7a87ff9 exited 1 the same way after Resolving refs... while several indexers shared one machine's memory, with cgroup OOM kills in the kernel log at that time.

Expected

  • Report the signal on stderr, e.g. codegraph: the indexer was killed by SIGKILL (out of memory?).
  • Exit with 128 + the signal number (137 for SIGKILL), as a shell would, so scripts and CI can tell a kill from a failure.

Related but different: #3137 is the MCP worker's watchdog respawn loop under memory exhaustion. This one is the one-shot CLI's exit path.

Lenguaje dominante
C
Estrellas
73.2k
Forks
4.7k
Merge medio
3 h 11 min
PR fusionados (30 d)
416

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de colbymchenry/codegraph

Todos los issues de colbymchenry/codegraph

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.