on-stop.sh slurps the entire transcript with jq -s every turn — ~1 GB RSS on long sessions, triggered a host OOM
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Leggi scripts/on-stop.sh e scripts/legacy/on-stop.sh, concentrandoti sulle due letture del transcript con jq -rs e su come estraggono l’ultimo prompt e l’ultima risposta. Riproduci il comportamento con un transcript JSONL di grandi dimensioni oppure esamina prima i filtri esistenti. Il lavoro è completato quando entrambi gli hook evitano di caricare l’intero transcript continuando a restituire il prompt e la risposta finali corretti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Shell
- Stelle
- 232
- Fork
- 56
- Merge medio
- 4g 15h
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di warpdotdev/claude-code-warp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
warpdotdev/claude-code-warp#63 · 2 commenti ·
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
warpdotdev/claude-code-warp#61 · 5 commenti · 5 reazioni ·
Tutte le issue di warpdotdev/claude-code-warp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
area:kubernetes area:site priority:high source:automated type:content-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
stephrobert/blog-roadmap#58 ·
-
Installer: install_sudoers_file schreibt nicht atomar und löscht bei Fehler eine gültige RegelApertaenhancement severity:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nushell/nushell#19176 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno