npm wrapper: SIGTERM/SIGINT orphans yaci-cli and leaves a stale PID file
@satran004 がすでに取り組んでいます。
2026年11月10日 から。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 55/100
調査の方向性
Start in start.mjs, where the npm wrapper spawns yaci-cli and registers its close handler that removes ~/.yaci-cli/yaci-cli.pid; the signal forwarding belongs next to that spawn. Reproduce by running yaci-devkit up, sending SIGTERM to the wrapper PID, and checking with ps that the children are gone and the PID file is removed. Done when the wrapper forwards SIGINT, SIGTERM and SIGHUP and the stale PID file check verifies the process is still yaci-cli before killing it.
索引モデルが issue の本文から書いたものです。
説明
Problem
The npm wrapper (start.mjs) spawns yaci-cli but installs no signal handlers. When the wrapper process alone is signalled, which is what a script, test runner or process manager does when it stops the yaci-devkit PID it started:
- Node exits right away and
yaci-cliis orphaned (reparented to PID 1), still running the node, submit-api, ogmios and yaci-store. - The
closehandler that removes~/.yaci-cli/yaci-cli.pidnever runs, so the PID file is left behind. - On the next
yaci-devkitrun,killProcessTreesends SIGTERM to the children of the PID in that file and SIGKILL to the PID itself, without checking that it is stillyaci-cli. If the PID has been reused, an unrelated process gets killed.
An interactive Ctrl-C mostly works, because the terminal sends SIGINT to the whole foreground process group, yaci-cli included. The problem shows up when there is no terminal, e.g. in CI or in a just test / npm test script that starts a throwaway devnet and stops it afterwards.
This looks like one of the edge cases mentioned in #94.
Reproduce
Linux x64, @bloxbean/yaci-devkit 0.12.0, Node 24:
yaci-devkit up --enable-yaci-store </dev/null >up.log 2>&1 &
W=$!
# wait until http://localhost:8080/api/v1/blocks/latest responds
kill -TERM "$W"
sleep 5
ps -ef | grep -E 'yaci-cli|cardano-node|ogmios|yaci-store' # all still running
cat ~/.yaci-cli/yaci-cli.pid # still there
Observed after the SIGTERM:
PID PPID COMMAND
1607653 1 yaci-cli
1607821 1607820 cardano-node
1607837 1607834 cardano-submit-
1607884 1607880 ogmios
1607899 1607653 yaci-store-n2c
pidfile: 1607653
Suggested fix
In start.mjs:
-
Forward SIGINT, SIGTERM and SIGHUP to the child and keep waiting for it, so the existing
closehandler removes the PID file and exits with the child's code:for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) { process.on(sig, () => child.kill(sig)); } -
Before killing the PID from a leftover PID file, check that the process is still
yaci-cli(e.g.ps -p <pid> -o comm=on Linux and macOS) and only remove the file otherwise.
A non-interactive way to stop a running devkit (say yaci-devkit down) would also help scripts that started it in another process.
Workaround
We currently start the devkit in its own process group (setsid) and signal the whole group on teardown, then remove the PID file if its PID is no longer alive.
- 主要言語
- Java
- スター
- 70
- フォーク
- 21
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bloxbean/yaci-devkit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
bloxbean/yaci-devkit#87 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
bloxbean/yaci-devkit#221 · コメント 2 件 · リアクション 1 件 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
bloxbean/yaci-devkit#207 ·
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
bloxbean/yaci-devkit#197 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
bloxbean/yaci-devkit#187 ·
bloxbean/yaci-devkit の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bloxbean/yaci-store#1445 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
Spare Permissionオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
Etar-Group/Etar-Calendar#2234 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] MCP resources-as-tools drops invocation context when listing templates対応中かも @CryoThrust が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
langchain4j/langchain4j#7320 ·
メンテナーはふだん 1 日以内に返信