Skip to content

Improve VS Code extension LSP lifecycle error handling#10756

Open
RodgeFu wants to merge 2 commits into
microsoft:mainfrom
RodgeFu:tel-improve2
Open

Improve VS Code extension LSP lifecycle error handling#10756
RodgeFu wants to merge 2 commits into
microsoft:mainfrom
RodgeFu:tel-improve2

Conversation

@RodgeFu
Copy link
Copy Markdown
Contributor

@RodgeFu RodgeFu commented May 21, 2026

Improve VS Code extension error handling based on telemetry from current compiler usage.

Summary:

  • Add targeted handling for known LSP lifecycle race errors during start/stop/dispose transitions so expected shutdown/restart conditions no longer surface as noisy unhandled failures.
  • Treat VS Code window-close prompt cancellation as a normal cancellation path instead of an unexpected startup error.
  • Dispose the previous LSP client during recreation so resources and registered commands are cleaned up before the next client starts.
  • Keep unknown failures visible so telemetry can still surface real bugs instead of broadly suppressing errors.
  • Scope the strategy to the latest compiler behavior (1.12 telemetry), with no special handling for older compiler versions, to keep the changes focused and minimal.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/typespec-vscode@10756

commit: 8b530f6

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

All changed packages have been documented.

  • typespec-vscode
Show changes

typespec-vscode - fix ✏️

Improve VS Code extension error handling for LSP lifecycle races observed in telemetry.

@azure-sdk-automation
Copy link
Copy Markdown

azure-sdk-automation Bot commented May 21, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

await oldClient?.stop();
// Use dispose() instead of stop() to ensure proper cleanup even when the old client
// is in StartFailed state. stop() skips cleanup when needsStop() returns false
// (e.g. after a failed start), which can leave commands like 'typespec.applyCodeFix'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this feels like a bug in the extension system of vscode? Do they have an issue for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ide Issues for VS, VSCode, Monaco, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants