claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Bug] PermissionRequest hook process not terminated on terminal response

Open hiragram opened this issue 1 month ago • 1 comments

Bug Description Title: PermissionRequest hook process is not terminated when user responds via terminal

Description:

When using a PermissionRequest hook that waits for external approval (e.g., Slack), if the user responds directly in the terminal instead of through the external system, the hook process continues running indefinitely.

Current Behavior:

  • Hook process starts and waits for external response (e.g., Slack button click)
  • User answers via terminal UI instead
  • Claude Code accepts the terminal response and continues
  • Hook process is NOT terminated - no SIGTERM, SIGINT, or any signal is sent
  • No additional stdin is provided to notify the hook
  • Hook process runs forever, consuming resources

Expected Behavior: One of the following:

  1. Send SIGTERM to the hook process when the permission prompt is resolved via terminal
  2. Send a JSON message to stdin indicating cancellation (e.g., {"cancelled": true})
  3. Close stdin to signal that the response is no longer needed

Impact:

  • Zombie processes accumulate
  • External systems (Slack) show stale UI with buttons that no longer function
  • Resource waste (CPU, memory, socket connections)

Reproduction:

  1. Configure a PermissionRequest hook that waits for external input
  2. Trigger a tool that requires permission (e.g., AskUserQuestion)
  3. Answer via terminal instead of the hook's external system
  4. Observe that the hook process continues running (ps aux | grep <hook>)

Environment:

  • Claude Code CLI
  • macOS

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.0.76
  • Feedback ID: d716f43d-7667-474e-bdcf-799950f9bfd1

Errors

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/hiragram/.local/share/claude/versions/2.0.76 (expected in multi-process scenarios)\n    at XZR (/$bunfs/root/claude:2430:2165)\n    at fUA (/$bunfs/root/claude:2430:1885)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-12-26T14:57:29.921Z"},{"error":"Error: Request was aborted.\n    at makeRequest (/$bunfs/root/claude:801:3940)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-12-26T15:01:10.407Z"},{"error":"Error: Request was aborted.\n    at makeRequest (/$bunfs/root/claude:801:3940)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-12-26T15:02:39.458Z"},{"error":"Error: Request was aborted.\n    at _createMessage (/$bunfs/root/claude:458:3157)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-12-26T15:06:16.472Z"},{"error":"Error: Request was aborted.\n    at makeRequest (/$bunfs/root/claude:801:3940)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-12-26T15:11:26.295Z"},{"error":"Error: Request was aborted.\n    at _createMessage (/$bunfs/root/claude:458:3157)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-12-26T15:12:08.621Z"},{"error":"Error: Request was aborted.\n    at makeRequest (/$bunfs/root/claude:801:3940)\n    at processTicksAndRejections (native:7:39)","timestamp":"2025-12-26T15:12:37.830Z"}]

hiragram avatar Dec 26 '25 15:12 hiragram

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/15400
  2. https://github.com/anthropics/claude-code/issues/12176

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Dec 26 '25 15:12 github-actions[bot]