Repository navigation
Keep the hook server listening after a failed accept or pipe connect - #872
Conversation
macOS: a failed accept() no longer ends the server thread. Transient errors (EINTR, ECONNABORTED) retry at once, others after 100 ms. Windows: a pipe instance whose connect failed is replaced by a fresh one, created before the old one is dropped, so a listening instance always exists. Fixes Louis-CFM#853 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested the Windows side on Windows 11 Pro 26H2. It builds, I tried to reproduce #853 by hammering the relay pipe (8 workers opening and closing connections for 10 s). The pipe did go dead, but not the way #853 describes: Coucou itself crashed with heap corruption ( The crash is a known mio 1.2.3 bug in Windows named pipes (tokio-rs/mio#2011), fixed in mio 1.2.4. I opened #911 with that bump: same test, no crash. So I couldn't trigger the |
Fixes #853
macOS —
HookServer.swiftA failed
accept()used tobreakout of the loop, so the server thread ended for good: the notch stopped updating and permission hooks fell back to the terminal until Coucou was relaunched. The loop now keeps going: transient errors (EINTR,ECONNABORTED) retry at once, anything else (e.g.EMFILE) after 100 ms, so a persistent error can't spin the CPU.Windows —
pipe.rsWhen
connect()failed, the loop retried on the same pipe instance, which fails the same way forever (ERROR_NO_DATAafter a client connected and closed first). The failed instance is now replaced by a fresh one, created before the old one is dropped, so a listening instance always exists.Testing
xcodebuild -scheme NotchBuddy -configuration Debug buildsucceeds;scripts/test-claude-hooks.shpasses.accept()/connect()paths themselves weren't reproduced on a device, same as in the issue.🤖 Generated with Claude Code