From b8f6fbe92afd8da76471d1a250fd25c835700e20 Mon Sep 17 00:00:00 2001 From: Shubham Sharma Date: Thu, 2 Jul 2026 03:40:24 +0530 Subject: [PATCH] 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 --- hooks/ponytail-mode-tracker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/hooks/ponytail-mode-tracker.js b/hooks/ponytail-mode-tracker.js index 5e85937..a0d7009 100644 --- a/hooks/ponytail-mode-tracker.js +++ b/hooks/ponytail-mode-tracker.js @@ -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 {