Skip to content

Conversation

@burkeholland
Copy link

Ensure proper timeout management in the CopilotSession class to confirm the process exists upon closure. Clear the timeout immediately after race completes.

@burkeholland burkeholland requested a review from a team as a code owner January 21, 2026 00:20
Copilot AI review requested due to automatic review settings January 21, 2026 00:20
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 memory leak in the sendAndWait method of the CopilotSession class by ensuring the timeout is properly cleared after Promise.race completes. The previous implementation created a timeout but never cleared it when the idle promise resolved first, leaving the timeout callback queued in the event loop.

Changes:

  • Added timeout ID tracking to capture the setTimeout return value
  • Wrapped Promise.race in a try-finally block to guarantee timeout cleanup
  • Added clearTimeout call in the finally block to prevent memory leaks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant