Skip to content

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

Open
Lakshya77089 wants to merge 2 commits into
DietrichGebert:mainfrom
Lakshya77089:fix/stdin-error-handler-147
Open

fix: handle stdin error in ponytail-mode-tracker to avoid uncaught crash (#147)#150
Lakshya77089 wants to merge 2 commits into
DietrichGebert:mainfrom
Lakshya77089:fix/stdin-error-handler-147

Conversation

@Lakshya77089

@Lakshya77089 Lakshya77089 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #147. hooks/ponytail-mode-tracker.js registered stdin.on('data') and stdin.on('end') but no stdin.on('error') handler. When stdin closes abnormally (broken pipe, parent crash), Node emits an error event on the stream; with no listener this surfaces as an uncaught exception, crashing the hook with a non-zero exit code.

Fix

Register an error handler that calls process.exit(0) before the data/end listeners. This preserves the hook contract — always exit 0, never block session start.

let input = '';
// Exit cleanly if stdin errors (broken pipe, parent crash) — never block session start
process.stdin.on('error', () => { process.exit(0); });
process.stdin.on('data', chunk => { input += chunk; });

Notes

  • This is the only stdin-reading hook in hooks/, so no other files need the same change.
  • Severity per the issue: HIGH — unhandled stream error → uncaught exception → hook crashes non-zero.

The headline benchmark is single-shot completions; a Notes bullet
generalized 'the cost gap widens further in ponytail's favor' to real
sessions. Independent multi-turn Cursor-SDK A/B (DietrichGebert#121) shows that on
large completion-forced tasks ponytail ON can raise tool calls and
tokens (more reading before writing) while shrinking output — net cost
either way; the win is clearest on snowball-prone/blocked tasks. Scope
the single-shot claim and add a 'saves vs. costs' section, plus the
skillCount-is-availability-not-usage clarification.
…ash (DietrichGebert#147)

Register a process.stdin 'error' handler so an abnormal stdin close
(broken pipe, parent crash) exits cleanly instead of throwing an
uncaught exception. process.exit(0) preserves the hook contract:
always exit 0, never block session start.
@Lakshya77089 Lakshya77089 force-pushed the fix/stdin-error-handler-147 branch from 5d47ad2 to 1054075 Compare June 18, 2026 10:55
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.

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

1 participant