fix: handle stdin error in ponytail-mode-tracker to avoid uncaught crash (#147) (#227)

Without a stdin 'error' listener, a broken pipe or parent-process crash
causes Node to emit an unhandled error event on the stream, which becomes
an uncaught exception and crashes the hook with a non-zero exit code.

Add process.stdin.on('error', () => process.exit(0)) before the data/end
listeners. Exiting 0 on error keeps the hook contract: always exit cleanly,
never block session start.

Fixes #147
This commit is contained in:
Shubham Sharma 2026-07-02 03:40:24 +05:30 committed by GitHub
parent 7eda70d30f
commit b8f6fbe92a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 0 deletions

View File

@ -6,6 +6,7 @@ const { getDefaultMode, isDeactivationCommand } = require('./ponytail-config');
const { clearMode, setMode, writeHookOutput } = require('./ponytail-runtime');
let input = '';
process.stdin.on('error', () => process.exit(0)); // broken pipe / parent crash: exit clean, never block session
process.stdin.on('data', chunk => { input += chunk; });
process.stdin.on('end', () => {
try {