Skip to content

fix(nodejs): handle stdio stdin errors#1584

Merged
SteveSandersonMS merged 4 commits into
github:mainfrom
sjh9714:fix-stdio-error-teardown
Jun 24, 2026
Merged

fix(nodejs): handle stdio stdin errors#1584
SteveSandersonMS merged 4 commits into
github:mainfrom
sjh9714:fix-stdio-error-teardown

Conversation

@sjh9714

@sjh9714 sjh9714 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1427.

Unexpected stdin pipe errors from a spawned stdio runtime no longer get re-thrown from the EventEmitter error listener. The Node SDK now routes that condition through connection disposal, preserving the forceStop() guard and letting the existing JSON-RPC close/error handlers tear the client down.

Changes

  • Replace the stdio child stdin error rethrow with scoped connection disposal.
  • Add a regression test that emits a broken-pipe error on child stdin and verifies the SDK does not throw and disposes the connection.

Testing

  • npm ci from nodejs/
  • npm ci from test/harness/
  • npm test -- test/client.test.ts -t "disposes the stdio connection when child stdin emits an error" from nodejs/ (failed before the fix, passed after)
  • npm test -- test/client.test.ts from nodejs/
  • npm test -- --exclude 'test/e2e/**' from nodejs/
  • npm run lint from nodejs/
  • npm run typecheck from nodejs/
  • npm run format:check from nodejs/
  • npm run build from nodejs/
  • git diff --check
  • git diff --check origin/main...HEAD

Full e2e tests were not run locally.

Note: I used Codex while preparing this change, reviewed the final diff, and ran the listed checks locally.

@sjh9714 sjh9714 requested a review from a team as a code owner June 5, 2026 15:32
SteveSandersonMS and others added 2 commits June 24, 2026 13:41
Keep the stdin "error" handler's no-throw teardown, but stash the
failure reason on a private field and surface it via the existing
logLevel-gated debug logger instead of discarding it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SteveSandersonMS

Copy link
Copy Markdown
Contributor

Thanks for the fix! I pushed a small maintainer follow-up that keeps the no-throw stdio teardown behavior, while preserving the stdin error reason by stashing it and emitting it through the existing logLevel-gated debug logging.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SteveSandersonMS SteveSandersonMS added this pull request to the merge queue Jun 24, 2026
Merged via the queue into github:main with commit 460b48a Jun 24, 2026
22 checks passed
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.

CopilotClient stdin error handler re-throws inside an EventEmitter callback, causing uncaughtException

2 participants