Skip to content

Sync with template: Fix duplicate server handlers on concurrent restarts#401

Merged
edvilme merged 1 commit intomainfrom
sync/template-pr-259-e17937cb5e68aab5
Feb 25, 2026
Merged

Sync with template: Fix duplicate server handlers on concurrent restarts#401
edvilme merged 1 commit intomainfrom
sync/template-pr-259-e17937cb5e68aab5

Conversation

@edvilme
Copy link
Contributor

@edvilme edvilme commented Feb 25, 2026

  • Move _disposables cleanup outside lsClient guard in restartServer() so disposables are always released, even when no previous client existed.
  • Wrap lsClient.stop() in deactivate() with try/catch to prevent unhandled rejections during extension deactivation.

Source: microsoft/vscode-python-tools-extension-template#259

- Move _disposables cleanup outside lsClient guard in restartServer() so
  disposables are always released, even when no previous client existed.
- Wrap lsClient.stop() in deactivate() with try/catch to prevent unhandled
  rejections during extension deactivation.

Source: microsoft/vscode-python-tools-extension-template#259

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@edvilme edvilme requested a review from Copilot February 25, 2026 23:07
Copy link

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 race condition issue where duplicate server handlers could be registered during concurrent server restarts. The fix ensures proper cleanup of disposables and handles potential errors during server shutdown.

Changes:

  • Move disposable cleanup outside the lsClient guard in restartServer() to ensure cleanup occurs even when no previous client existed
  • Add error handling around lsClient.stop() in deactivate() to prevent unhandled promise rejections

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/extension.ts Wraps lsClient.stop() with try/catch to handle deactivation errors gracefully
src/common/server.ts Moves _disposables cleanup outside the lsClient guard to ensure consistent cleanup

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

@edvilme edvilme added bug Issue identified by VS Code Team member as probable bug debt labels Feb 25, 2026
@edvilme edvilme enabled auto-merge (squash) February 25, 2026 23:23
Copy link

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

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

Approved via Review Center.

@edvilme edvilme merged commit af0f90a into main Feb 25, 2026
25 of 26 checks passed
@edvilme edvilme deleted the sync/template-pr-259-e17937cb5e68aab5 branch February 25, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants