Skip to content

Missing stdin error handler in ponytail-mode-tracker.js causes uncaught exception on broken pipe #147

@HetCreep

Description

@HetCreep

Version

v4.7.0 (verified on tag v4.7.0, 2026-06-18)

Problem

hooks/ponytail-mode-tracker.js lines 9-10 register stdin.on('data') and stdin.on('end') with no stdin.on('error') handler.

When stdin closes abnormally (broken pipe, parent crash), Node emits an unhandled error event on the stream. Without a listener this becomes an uncaught exception, crashing the hook process with a non-zero exit code.

Code

javascript let input = ''; process.stdin.on('data', chunk => { input += chunk; }); process.stdin.on('end', () => { // ... no stdin.on('error') handler

Fix

javascript process.stdin.on('error', () => { process.exit(0); }); let input = ''; process.stdin.on('data', chunk => { input += chunk; }); process.stdin.on('end', () => { ... });

process.exit(0) keeps the hook contract: always exit 0, never block session start.

Severity

HIGH - Unhandled stream error ? uncaught exception ? hook crashes non-zero

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions