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

Do not crash server if we fail to determine language for non-mutating request #75509

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Oct 14, 2024

Resolves dotnet/vscode-csharp#7656

Sometimes VSCode will send a request or two with the old URI after it renames a temporary file. When we close the file we lose the languageId that they told us about in didOpen (we drop the file info for it) and the server crashes.

Since this is a recoverable error, we should avoid crashing. Instead, we just fail the request and allow the server to continue running, unless it is a mutating request.

@dibarbet dibarbet requested a review from a team as a code owner October 14, 2024 23:33
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 14, 2024
@dibarbet dibarbet changed the title Warn instead of crashing if we get a request with unknown language Do not crash server if we fail to determine language for non-mutating request Oct 15, 2024
ex = null;
return language;
}
catch (Exception exception)
Copy link
Member

Choose a reason for hiding this comment

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

do we want to report this somehow? it would be nice if we could push on this to get fixed at some point.

Copy link
Member

Choose a reason for hiding this comment

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

catching naked exception feels... bad.

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

i'd like us to be a little more careful/precise in exception handling.

@CyrusNajmabadi
Copy link
Member

Since this is a recoverable error

Agreed, this is recoverable. From an impl perspective though, i'd prefer we check explicitly for this, and then fail gracefully vs throwing exceptions and catching all exceptions.

@dibarbet
Copy link
Member Author

Agreed, this is recoverable. From an impl perspective though, i'd prefer we check explicitly for this, and then fail gracefully vs throwing exceptions and catching all exceptions.

I can do this to have the langue provider return if it could find it (instead of throwing internally). However I will still need to create an exception to serialize down to the client so it can observe the failure. But I can do that inside the queue handling if you'd prefer.

@CyrusNajmabadi
Copy link
Member

But I can do that inside the queue handling if you'd prefer.

Yes please.

@dibarbet dibarbet merged commit 5a5854a into dotnet:main Oct 16, 2024
25 checks passed
@dibarbet dibarbet deleted the warn_if_unknown_language branch October 16, 2024 15:38
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Language server sometimes crashes when saving a new C# file
4 participants