Bug: `RangeError: Out of memory` crash after `git commit` fails due to renamed hook script
Title: Bug: RangeError: Out of memory crash after git commit fails due to renamed hook script
Body:
Description
When asking Claude Code to perform a git commit and push, the session crashed with a RangeError: Out of memory. This occurred after a session where I had used Claude to rename a configured hook script (activity_hook.sh -> activity_hook.sh.deprecated).
It appears that after the file was renamed, Claude's hook runner did not update its internal state and continued to attempt executing the hook from its old, now non-existent, path. This led to a "No such file or directory" error, followed by a long "Determining..." phase, and ultimately a fatal out-of-memory crash.
Steps to Reproduce
- In a git repository, configure a hook in
.claude/settings.json, for example, aPreToolUsehook pointing to.claude/hooks/activity_hook.sh. - Start an interactive
claudesession. - Use Claude to rename the hook script (e.g.,
mv .claude/hooks/activity_hook.sh .claude/hooks/activity_hook.sh.deprecated). - Ask Claude to perform an action that would trigger the now-moved hook, such as
commit and push. - Observe the hook execution failure and subsequent crash.
Expected Behavior
Claude should recognize that the hook script at the configured path no longer exists. Ideally, it would fail gracefully, report that the hook is missing, and continue the session without crashing. It should not attempt to execute a script from a path it was responsible for moving within the same session.
Actual Behavior
- Claude attempts to execute the hook from the original, now non-existent, path.
- It logs a
No such file or directoryerror for bothPreToolUseandStophook events. - The agent gets stuck in a "Determining..." state for an extended period (75s+).
- The entire process crashes with a
RangeError: Out of memory.
Environment
- Claude Code Version: ~1.0.80
- Operating System: macOS (arm64)
- Shell: Zsh
- Runtime: Bun v1.2.19
Terminal Output / Logs
<details>
<summary>Click to expand full terminal output</summary>
Bash(git status)
⎿ On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
… +10 lines (ctrl+r to expand)
⏺ PreToolUse:Bash [/Users//Desktop/2025-08-09-statusline/.claude/hooks/activity_hook.sh] failed with
non-blocking status code 127: /bin/sh:
/Users/user/Desktop/2025-08-09-statusline/.claude/hooks/activity_hook.sh: No such file or directory
⏺ Stop [/Users/user/Desktop/2025-08-09-statusline/.claude/hooks/activity_hook.sh] failed with non-blocking status
code 127: /bin/sh: /Users/user/Desktop/2025-08-09-statusline/.claude/hooks/activity_hook.sh: No such file or
directory
✶ Determining… (75s · ⚒ 599 tokens · esc to interrupt)
⎿ Tip: Run /terminal-setup to enable convenient terminal integration like Shift + Enter for new line and more
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
⏵⏵ accept edits on (shift+tab to cycle)
1305 | - NEVER update the git config
1306 | - DO NOT use the ${J6.name} or ${L2} tools
1307 | - Return the PR URL when you're done, so the user can see it
1308 |
1309 | # Other common operations
1310 | `);if(X!==-1){if(Y=Z.substring(0,X),Y.length+1>G)return`${Y.substring(0,G-1)}\u2026`;return`${Y}\u2026`}}if(Y.length<=G)return Y;return`${Y.substring(0,G-1)}\u2026`}function Mv(Z){if(Z<60000){let X=(Z/1000).toFixed(1);return`${X.endsWith(".0")?X.slice(0,-2):X}s`}let G=Math.floor(Z/3600000),W=Math.floor(Z%3600000/60000),Y=(Z%60000/1000).toFixed(1);if(G>0)return`${G}h ${W}m ${Y}s`;if(W>0)return`${W}m ${Y}s`;return`${Y}s`}function p6(Z){let G=Z>=1000;return new Intl.NumberFormat("en",{notation:"compact",minimumFractionDigits:G?1:0,maximumFractionDigits:1}).format(Z).toLowerCase()}function PE0(Z,G={}){let{style:W="narrow",numeric:Y="always",now:X=new Date}=G,B=Z.getTime()-X.getTime(),D=Math.trunc(B/1000),J=[{unit:"year",seconds:31536000,shortUnit:"y"},{unit:"month",seconds:2592000,shortUnit:"mo"},{unit:"week",seconds:604800,shortUnit:"w"},{unit:"day",seconds:86400,shortUnit:"d"},{unit:"hour",seconds:3600,shortUnit:"h"},{unit:"minute",seconds:60,shortUnit:"m"},{unit:"second",seconds:1,shortUnit:"s"}];for(let{unit: | ... truncated
RangeError: Out of memory
at <anonymous> (/$bunfs/root/claude:1310:2540)
at emit (node:events:95:22)
at addChunk (internal:streams/readable:265:47)
at readableAddChunkPushByteMode (internal:streams/readable:243:18)
at handleArrayBufferViewResult (internal:streams/native-readable:79:16)
at <anonymous> (internal:streams/native-readable:43:68)
Bun v1.2.19 (macOS arm64)
➜ ~/Desktop/2025-08-09-statusline git:(main) ✗
</details>
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗