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

未关闭 适合新手
#3,277 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
node.js, typescript, wasm
领域
backend, cli

调研方向

从 src/extraction/wasm-runtime-flags.ts 开始,重点查看 relaunchWithWasmRuntimeFlagsIfNeeded,并检查 spawnSync 的结果如何决定 CLI 退出状态。使用 issue 中限制内存的命令复现子进程被信号终止的情况,然后检查此重新启动路径的现有测试。当被信号终止的子进程产生一条 stderr 消息,指出信号名称和预期的 shell 风格退出代码时,即为完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
C
星标
73.2k
派生
4.7k
平均合并
3 小时 11 分钟
30 天内合并 PR
416

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

colbymchenry/codegraph 的其他 Issue

查看 colbymchenry/codegraph 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。