SessionEnd hook reports 'Hook cancelled' even when hook exits 0 immediately

Resolved 💬 0 comments Opened May 29, 2026 by Pilscheur Closed Jun 1, 2026

Description

A SessionEnd hook that exits with code 0 within milliseconds is still reported as failed: Hook cancelled in the terminal output at the end of every session.

Steps to reproduce

  1. Add a SessionEnd hook to ~/.claude/settings.json:

``json
"hooks": {
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "/path/to/hook.sh"
}
]
}
]
}
``

  1. Make hook.sh a script that exits 0 immediately (e.g. #!/bin/bash + exit 0)
  2. End a session with /exit

Expected behavior

No error message, or a success confirmation.

Actual behavior

Resume this session with:
claude --resume <session-id>
SessionEnd hook [/path/to/hook.sh] failed: Hook cancelled

This appears even when the hook script:

  • Exits with code 0
  • Completes in under 10ms
  • Has trap '' INT TERM HUP to ignore all catchable signals
  • Has been verified to do its work correctly (side effects happen)

Additional context

  • Tested with both a simple exit 0 script and a more complex script that forks work to a double-forked background process before exiting
  • The hook's actual work (writing to a file) completes successfully — the "failure" is purely a display artifact
  • The message appears consistently on every /exit, not just occasionally
  • Platform: macOS 26 (Darwin 25.5.0)

Request

Either:

  • Don't show "failed: Hook cancelled" when the hook exits 0, or
  • Clarify what "Hook cancelled" means and provide a way to suppress the message for hooks that intentionally run fire-and-forget

View original on GitHub ↗