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:
parent
7eda70d30f
commit
b8f6fbe92a
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue