Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never return error for diagnostics request #981

Merged

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Nov 27, 2023

VS Code does not request diagnostics again for a document if the diagnostics request failed. Since sourcekit-lsp usually recovers from failures (e.g. after sourcekitd crashes), this is undesirable. Instead of returning an error, return empty results.

@ahoppen ahoppen requested a review from benlangmuir as a code owner November 27, 2023 22:47
@ahoppen
Copy link
Member Author

ahoppen commented Nov 27, 2023

@swift-ci Please test

Comment on lines 1068 to 1070
// VS Code does not request diagnostics again for a document if the diagnostics request failed.
// Since sourcekit-lsp usually recovers from failures (e.g. after sourcekitd crashes), this is undesirable.
// Instead of returning an error, return empty results.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a VS Code thing or an extension thing? Because IMO it's useful to distinguish between having results and not (consider eg. deciding whether to replace previous issues or not).

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIK it’s a VS Code thing. @adam-fowler to confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a VSCode thing. The extension doesn't have control over when VSCode asks for diagnostics.

Out of interest the "failed" diagnostics request, does that mean no response was returned or that an error response was returned.

Copy link
Member Author

@ahoppen ahoppen Dec 5, 2023

Choose a reason for hiding this comment

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

By “failed” I meant an error response. The workaround for this issue is to always return empty diagnostics instead whenever we previously returned an error response.

VS Code does not request diagnostics again for a document if the diagnostics request failed. Since sourcekit-lsp usually recovers from failures (e.g. after sourcekitd crashes), this is undesirable. Instead of returning an error, return empty results.
@ahoppen ahoppen force-pushed the ahoppen/never-error-for-diagnostics-request branch from 32cb77f to 4c8aea2 Compare November 28, 2023 03:39
@ahoppen
Copy link
Member Author

ahoppen commented Nov 28, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Nov 28, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit f293741 into swiftlang:main Dec 5, 2023
@ahoppen ahoppen deleted the ahoppen/never-error-for-diagnostics-request branch December 5, 2023 18:03
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.

3 participants