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(lsp): handle get diagnostic errors better #14776

Merged
merged 2 commits into from
Jun 3, 2022

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Jun 2, 2022

This handles errors in getDiagnostics request where there are transient errors in getting the diagnostics which cause an output of:

ERROR TSLS = {}

In the debug console, which is distracting to users and doesn't impact the usage of the extension. Also, when one specifier causes an issue, all requested specifiers get dropped, which isn't ideal. This will handle the whole failure of getting diagnostics better.

@kitsonk kitsonk requested a review from dsherret June 2, 2022 02:00
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM thanks for looking into this!

...languageService.getSuggestionDiagnostics(specifier),
...languageService.getSyntacticDiagnostics(specifier),
];
} catch {
Copy link
Member

Choose a reason for hiding this comment

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

Huh, interesting. Would it make sense to do this per method call? I guess not since these are transient errors? What kind of errors get thrown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried it, but if one failed, they all failed... it throws a {} (yeah, just an object and I can't find where it is actually occurring in typescript.js, but it just fails some point, I suspect because the internal state of stuff is temporarily wrong)

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to know exactly what’s happening, but this seems fine to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at all the code, I suspect it is some sort of debug logging/failure that is occurring, related to an attempt to find a source file, but it being in a bad state it non-critically debug errors, but because we don't fully implement the debug host, instead of it being something meaningful handled by the TypeScript internal debugger, it bubbles up as a {}.

One thing we don't do is validate on the getDiagnostics that all the specifiers have source files... actually that is an interesting point, I will look into that. It could be we just need to go grab any missing source files, where we are asking for diagnostics for source files that aren't in tsc yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, found it, it was ts.OperationCanceledException being thrown, which we should just swallow like we do with the OperationCanceledError, which explains the transient nature of the error. I have refactored it again to better handle that error.

Copy link
Member

Choose a reason for hiding this comment

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

Perfect! Thanks for looking into it.

@kitsonk kitsonk requested a review from dsherret June 3, 2022 01:14
@kitsonk kitsonk merged commit 5692132 into denoland:main Jun 3, 2022
@kitsonk kitsonk deleted the fix_error_tsls branch June 3, 2022 12:23
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

2 participants