Skip to content

fix: guard final writeHookOutput against stdout EPIPE in ponytail-activate (#149)#152

Merged
DietrichGebert merged 1 commit into
DietrichGebert:mainfrom
Lakshya77089:fix/guard-final-writehookoutput-149
Jun 18, 2026
Merged

fix: guard final writeHookOutput against stdout EPIPE in ponytail-activate (#149)#152
DietrichGebert merged 1 commit into
DietrichGebert:mainfrom
Lakshya77089:fix/guard-final-writehookoutput-149

Conversation

@Lakshya77089

@Lakshya77089 Lakshya77089 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #149. The final writeHookOutput('SessionStart', mode, output) call at ponytail-activate.js:72 was the only operation in the file left outside a try/catch — setMode and the statusline detection are both guarded.

writeHookOutput ends in a bare process.stdout.write(...) (ponytail-runtime.js:42) with no internal guard, so if stdout is closed or the pipe to the host breaks at hook exit, process.stdout.write throws EPIPE, which becomes an uncaught exception and crashes the hook with a non-zero exit code.

Fix

Wrap the final write in try/catch, matching the never-block-session-start posture used everywhere else in the file:

try {
  writeHookOutput('SessionStart', mode, output);
} catch (e) {
  // Silent fail — stdout closed/EPIPE at hook exit must not surface as a hook failure
}

node --check passes.

Credit

Thanks to @Indrajeet-Badhel for triaging this issue and confirming the approach — this PR implements the same guard discussed there.

…ivate (DietrichGebert#149)

The final writeHookOutput('SessionStart', ...) call was the only operation
in the file outside a try/catch. writeHookOutput ends in a bare
process.stdout.write, so a closed stdout / broken pipe (EPIPE) at hook exit
throws uncaught and crashes the hook with a non-zero exit code. Wrap it to
match the file's existing never-block-session-start posture.
@Lakshya77089 Lakshya77089 force-pushed the fix/guard-final-writehookoutput-149 branch from 22f5708 to 2bc8947 Compare June 18, 2026 10:55
@DietrichGebert DietrichGebert merged commit c308541 into DietrichGebert:main Jun 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ponytail-activate.js: final writeHookOutput call is outside try/catch - stdout failure crashes hook

2 participants