SessionEnd hooks don't fire on API 500 errors
Resolved 💬 3 comments Opened Jan 22, 2026 by merlinmann Closed Jan 26, 2026
Problem
SessionEnd hooks configured in .claude/settings.json do not fire when a session terminates due to API 500 errors.
Expected behavior
SessionEnd hooks should fire on any session termination, including crashes, so users can implement auto-save/recovery mechanisms.
Actual behavior
When API Error 500 kills a session, the process terminates without triggering SessionEnd hooks. This defeats the purpose of having session-end automation for crash recovery.
Reproduction
- Configure a SessionEnd hook in
.claude/settings.json:
{
"hooks": {
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/save-session.sh",
"timeout": 15
}
]
}
]
}
}
- Trigger an API 500 error (e.g., by having PDFs in the project directory per #20018)
- Observe that the hook script is never executed
Environment
- Claude Code v2.1.17
- macOS (Apple Silicon)
- Opus 4.5
Additional context
This may also be a configuration format issue—the nested hooks arrays might be incorrect. Documentation on the exact schema for .claude/settings.json hooks would help.
Related: #20018 (PDF reading causes API 500)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗