[BUG] Notification Hook 10 second delay
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 1.0.69
- Operating System: Ubuntu 24.04.2
- Terminal: Terminal App
Bug Description
~8-10 second delay for Notification Hook
Steps to Reproduce
- Setup a hook for notifications
- Request Claude Code to go into a different directory in order to send me to trigger the notification hook.
Expected Behavior
The notification hook to query and execute immediately
Actual Behavior
[DEBUG] Matched 0 unique hooks for query "LS" (0 before deduplication) [DEBUG] Found 0 hook commands to execute
10 Second Delay
[DEBUG] Getting matching hook commands for Notification with query: undefined [DEBUG] Found 1 hook matchers in settings [DEBUG] Matched 1 unique hooks for query "no match query" (1 before deduplication) [DEBUG] Notification [echo "$(date): Notification hook triggered, playing sound" >> ~/.claude/hook.log && paplay ~/.claude/sounds/correct-answer.wav &] completed with status 0
Additional Context
+1 Having same issue
Environment
Platform:
-
[x] Anthropic API
-
Claude CLI version: 1.0.72
-
Operating System: Ubuntu 24.04.2
-
Terminal: Zsh
I've been battling with this for a TTS based on the notification hook. Mine isn't quite 10 seconds but it's lengthy. I though it was my hook handlers and have put extensive logging in my code and my hook handler in Python take 50ms total. Not great but definitely not the 3-6 second delay the hook shows. I have logging of the notification as the first thing that happens and I see the file get written ad is immediately followed by my TTS announcement.
I'm certain it is not my code.
Anthropic API
Claude CLI version: 1.0.72
Operating System: macOS Sequoia 15.6
Terminal: Zsh
same issue here
[DEBUG] Hooks: checkForNewResponses called
[DEBUG] Hooks: Found 0 total hooks in registry
[DEBUG] Hooks: checkForNewResponses returning 0 responses
then delay for 10~20s
I am on windows11, claude code 2.0.0,
CPU: AMD ryzen 9 9950X
Seems I fixed this issue by https://stackoverflow.com/questions/28507014/cygwin-commands-from-cmd-are-slow-from-bash-are-fast. Problem is cygwinis very slow when frist time called on windows.
A section in Cygwin's FAQ addresses slow startup times. Cygwin recently changed to using Active Directory lookups for authentication, rather than using flat files. Changing the defaults in /etc/nsswitch.conf from
passwd: files db group: files db to
passwd: files group: files skips the AD lookup. My Cygwin commands are now speedy again.
Has anyone got a fix on linux?
I'm also getting this
Bumping this
This problem is still happening.
im getting this bug too and its really disrupting my workflow at work!
Bumping this again
Bumping this
I want to be notified as soon as possible when Claude needs my attention. These 10 second delays are annoying.
@bcherny @ant-kurt @ashwin-ant Can you help with this? v2.0.37 included "Fixed how idleness is computed for notifications" but there's still a consistent ~10s delay in the notification pipeline.
Binary analysis (v2.0.55) shows a 6-second polling interval (setInterval with ewD=6000) in the notification check logic. The remaining ~4 seconds may be subprocess spawn overhead. On Windows/Cygwin, disabling AD lookups in nsswitch.conf reduces the delay, supporting this theory.
Relevant timing constants found in the bundled JS:
ewD=6000(notification polling interval)Tz=60000(hook execution timeout)asyncTimeout=15000(async hook timeout)messageIdleNotifThresholdMs=60000(idle notification threshold)
Exposing the polling interval as a configurable environment variable would help.
In the meanwhile I had Claude Code make a program that patches this bug on your local binary: https://gist.github.com/cool-RR/dab9b132fb607712a614d487dd554d29
For me it makes the notification hook have <1s delay. Use at your own risk.
I can confirm this bug on Linux with Claude Code 2.0.65. Seems to be much longer than 10 seconds for me though. I'd expect the notification to be instant.
Confirming this bug still exists on v2.0.76 (macOS)
This bug still exists on v2.1.11 on Mac
In the meanwhile I had Claude Code make a program that patches this bug on your local binary: gist.github.com/cool-RR/dab9b132fb607712a614d487dd554d29
For me it makes the notification hook have <1s delay. Use at your own risk.
thank you for this gist. I modified it to work with 2.1.x and included it in my MIT licensed tool, lemonaid: https://github.com/petergaultney/lemonaid/blob/main/src/lemonaid/claude/patcher.py
Seems I fixed this issue by https://stackoverflow.com/questions/28507014/cygwin-commands-from-cmd-are-slow-from-bash-are-fast. Problem is cygwinis very slow when frist time called on windows.
A section in Cygwin's FAQ addresses slow startup times. Cygwin recently changed to using Active Directory lookups for authentication, rather than using flat files. Changing the defaults in /etc/nsswitch.conf from passwd: files db group: files db to passwd: files group: files skips the AD lookup. My Cygwin commands are now speedy again.
UP the issue.
This fix is not working if using Native Install. I tested and it is only works with npm install on windows 11.
I'm seeing this bug on Mac v2.1.39 for Notification hooks as well. The Stop and SubagentStop fire immediately.