on-stop.sh slurps the entire transcript with jq -s every turn — ~1 GB RSS on long sessions, triggered a host OOM
まだ誰も着手していません。
評価
調査の方向性
scripts/on-stop.sh と scripts/legacy/on-stop.sh を読み、2 つの jq -rs による transcript の読み取りと、そこから最後の prompt と response をどのように抽出しているかに注目してください。大きな JSONL transcript を使って動作を再現するか、まず既存のフィルターを確認してください。両方の hook が transcript 全体を読み込まず、それでも正しい最後の prompt と response を返せれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
scripts/on-stop.sh reads the entire session transcript into memory twice at the end of every turn (jq -rs … "$TRANSCRIPT_PATH"). On a long session this makes jq use roughly 3× the transcript size in RAM. With a 318 MB transcript, jq reached ~955 MB RSS, and on a host with little free memory it triggered a global OOM. The kernel killed the user's systemd manager, and with it the tmux session running Claude Code.
Environment
- Plugin
warp@claude-code-warp2.1.0 - Linux (Debian 13, kernel 6.12), 12 GB RAM, no swap
- Claude Code in tmux over SSH; one long session (transcript 318 MB / ~106k lines)
What happened
At the end of a turn:
kernel: jq invoked oom-killer: ...
kernel: Out of memory: Killed process ... (systemd) ...
kernel: Out of memory: Killed process ... (jq) total-vm:966544kB, anon-rss:955692kB ...
systemd[1]: [email protected]: A process of this unit has been killed by the OOM killer.
The jq ran in the tmux scope, which points at the Stop hook. Killing the user manager took the tmux server and the Claude Code session down with it.
Cause
on-stop.sh runs jq -rs on the whole transcript twice, to extract the last user prompt and the last assistant response. -s slurps every line into one in-memory array, so memory grows with the whole session, although only the last prompt and response are needed. The work repeats on every turn.
Suggested fix
Both values are always near the end of the file, so read only the tail:
QUERY=$(tail -n 2000 "$TRANSCRIPT_PATH" | jq -rs '…same filter…' 2>/dev/null)
RESPONSE=$(tail -n 2000 "$TRANSCRIPT_PATH" | jq -rs '…same filter…' 2>/dev/null)
Transcript lines are self-contained JSON objects (JSONL), so tail -n never splits a record. On the same 318 MB transcript the tail is 3.7 MB, and the query still returns the correct last prompt. A streaming alternative (jq -c without -s, keeping the last match) would also work.
The same pattern is in scripts/legacy/on-stop.sh.
- 主要言語
- Shell
- スター
- 232
- フォーク
- 56
- 平均マージ
- 4日 15時間
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
warpdotdev/claude-code-warp のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
warpdotdev/claude-code-warp#63 · コメント 2 件 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
warpdotdev/claude-code-warp#61 · コメント 5 件 · リアクション 5 件 ·
warpdotdev/claude-code-warp の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws-samples/appmod-blueprints#972 ·
メンテナーはふだん 1 日以内に返信
-
status:needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
out-of-date
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
CachyOS/CachyOS-PKGBUILDS#1965 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Sorogate/example-consumer#14 ·