Skip to content

Add an LSP boot flag that enables flaky diagnostics tracking#4710

Open
weswigham wants to merge 6 commits into
microsoft:mainfrom
weswigham:add-flaky-diagnostics-tracking
Open

Add an LSP boot flag that enables flaky diagnostics tracking#4710
weswigham wants to merge 6 commits into
microsoft:mainfrom
weswigham:add-flaky-diagnostics-tracking

Conversation

@weswigham

@weswigham weswigham commented Jul 22, 2026

Copy link
Copy Markdown
Member

Specifically, the --lsp flag now allows a trackFlakyDiagnostics server init flag with values of none, log, or panic, which configure the LSP server to do extra work to track if and when we return diagnostics that users might find flaky or weirdly conditional. Correspondingly, there is a js/ts.server.trackFlakyDiagnostics flag with values log, panic, never, or auto. auto meaning log on vscode insiders or never elsewhere, operating similarly to the existing js/ts.server.showFailedResponses setting.

Under panic mode it panics and crashes the LS, like so:
image
otherwise under log mode it only quietly logs the error like so:
image

This can allow our fuzzer, end users, or telemetry to capture when the checker has an issue like those exposed in our tests over in #4527, and assist in tracking down the root cause so we don't have spurious errors that only-sometimes-appear.

Comment thread internal/lsp/server.go
s.logger.Error(diff)

if s.telemetryEnabled {
_ = sendNotification(s, lsproto.TelemetryEventInfo, lsproto.TelemetryEvent{

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm also sending a request failure telemetry event with a new flakeLog method if telemetry is enabled, too - with just the diagnostic codes in the payload. @DanielRosenwasser do you have any thoughts on that?

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.

It's not exactly the ideal way to do this, but it will automatically appear in the dashboards so it's probably fine for now.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds optional LSP diagnostic-instability tracking to help investigate issue #4527.

Changes:

  • Runs diagnostics before and after emit, logging, reporting, or panicking on differences.
  • Adds CLI modes and VS Code configuration.
  • Adds diagnostic comparison and formatting utilities.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/lsp/server.go Performs and reports flaky-diagnostic checks.
internal/lsp/lsproto/util.go Compares and formats diagnostics.
cmd/tsgo/lsp.go Adds the LSP startup flag.
_extension/src/client.ts Maps extension settings to CLI arguments.
_extension/package.json Declares the new setting.
_extension/package.nls.json Adds localized setting descriptions.

Comment thread _extension/src/client.ts Outdated
Comment thread internal/lsp/server.go
Comment thread internal/lsp/lsproto/util.go
Comment thread _extension/src/client.ts
Comment thread _extension/src/client.ts Outdated
@weswigham
weswigham force-pushed the add-flaky-diagnostics-tracking branch from 9a00d4c to 6ec948e Compare July 23, 2026 17:47
Comment thread _extension/package.json
Comment thread internal/lsp/lsproto/util.go Outdated
return false
}

func CompareDiagnostics(preEmit []*Diagnostic, postEmit []*Diagnostic, sanitizedDiffEnabled bool) (string, string) {

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.

Since this is specific to pre/post emit, should this be named differently? Perhaps it doesn't much matter but it is sort of special and in the lsproto package, whereas I sort of expected it to live somewhere else

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fair point - I've pushed the actual string generation out of lsproto, making CompareDiagnostics only do the set comparison.

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.

Er, well I meant moreso that all of this code is more specific to the flaky diag code and not inherent to lsproto, so could all be moved, no? But that's a bikeshed I know

Comment thread internal/lsp/server.go Outdated
@weswigham
weswigham requested a review from jakebailey July 23, 2026 20:41
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.

4 participants