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

fix: Added code to catch resolver exceptions if any. #2080

Merged
merged 13 commits into from
May 10, 2022

Conversation

MikaelMayer
Copy link
Member

@MikaelMayer MikaelMayer commented Apr 29, 2022

As a prevention measure for issues such as #2074
I added some code that catches exceptions coming from the Resolver so that it won't impact user experience in the IDE.
I also added some catching code for Ghost Diagnostics because they were impacted as well.
The result is a non-blocking diagnostic that does not crash the server anymore:
image
Moreover, it returns also all the other resolution errors so that users are not helpless:
image

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@MikaelMayer MikaelMayer marked this pull request as draft April 29, 2022 22:14
@MikaelMayer MikaelMayer marked this pull request as ready for review May 2, 2022 16:24
@MikaelMayer MikaelMayer changed the title Feat: Added code to catch resolver exceptions if any. fix: Added code to catch resolver exceptions if any. May 2, 2022
@MikaelMayer MikaelMayer self-assigned this May 2, 2022
visitor.Visit(symbolTable.CompilationUnit.Program);
return visitor.GhostDiagnostics;
} catch (Exception e) {
logger.LogDebug(e, "encountered an exception while getting ghost state diagnostics of {Name}", symbolTable.CompilationUnit.Name);
Copy link
Member

Choose a reason for hiding this comment

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

This will not be visible to users, right? Aren't these logs only written to disk in a somewhat hidden location?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes they are written next to DafnyLanguageServer.dll, and only if an option is activated.
But this kind of error can happen if the language server recovered from problematic resolving, and leaving the program in a state that the Ghost Diagnostic Collector is not assuming, so that's why it's less important.

@MikaelMayer MikaelMayer enabled auto-merge (squash) May 2, 2022 18:13
@keyboardDrummer
Copy link
Member

keyboardDrummer commented May 3, 2022

Can we add tests by using dependency injection to inject a broken implementation? The reason I ask is because having a reliable language server is so important and without tests it seems easy to lose the functionality you added in this PR again.

@MikaelMayer
Copy link
Member Author

Can we add tests by using dependency injection to inject a broken implementation? The reason I ask is because having a reliable language server is so important and without tests it seems easy to lose the functionality you added in this PR again.

Yes you're right.
Tests added.


[TestMethod]
public void EnsureResilienceAgainstErrors() {
// Builtins is null to trigger an error.
Copy link
Member

@keyboardDrummer keyboardDrummer May 6, 2022

Choose a reason for hiding this comment

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

It seems like this test relies on some badly defined API of DafnyPipeline.csproj, that it requires Builtins to be not null, to trigger the exception. I think it might be nicer if the test uses a more explicit API to trigger a failure, like mocking something from DafnyPipeline.csproj and letting the mock throw an Exception, but I imagine DafnyPipeline.csproj is not setup for being mocked.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes you identified this test correctly.
I don't see either how to mock the DafnyPipeline, so I took the route of the minimum working test for now.

@MikaelMayer MikaelMayer merged commit e349468 into master May 10, 2022
@MikaelMayer MikaelMayer deleted the feat-robustness-resolver branch May 10, 2022 19:53
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.

None yet

3 participants