Skip to content

fix: clear timeout timer in sendAndWait to prevent process hang#349

Merged
friggeri merged 1 commit intomainfrom
frg/fix-136
Feb 3, 2026
Merged

fix: clear timeout timer in sendAndWait to prevent process hang#349
friggeri merged 1 commit intomainfrom
frg/fix-136

Conversation

@friggeri
Copy link
Collaborator

@friggeri friggeri commented Feb 3, 2026

When idlePromise resolved first (successful response), the setTimeout timer kept running in the background, preventing Node.js from exiting until the timer fired.

Fixes #136

When idlePromise resolved first (successful response), the setTimeout timer
kept running in the background, preventing Node.js from exiting until the
timer fired.

Fixes #136
@friggeri friggeri requested a review from a team as a code owner February 3, 2026 23:38
Copilot AI review requested due to automatic review settings February 3, 2026 23:38
@friggeri friggeri mentioned this pull request Feb 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug where the Node.js process would hang after client.stop() was called due to an uncancelled timeout timer in the sendAndWait method. When the session became idle (successful response), the setTimeout timer continued running in the background, preventing the process from exiting until the timer expired.

Changes:

  • Capture the timeout ID from setTimeout in the sendAndWait method
  • Clear the timeout in the finally block to ensure cleanup in all code paths

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.

[TypeScript SDK] Process not returning properly after client stop / dangling promise in sendAndWait

1 participant