Skip to content

More robust error handling in the language server #53

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

Merged
merged 6 commits into from
Mar 3, 2021
Merged

Conversation

dfreeman
Copy link
Member

@dfreeman dfreeman commented Mar 2, 2021

This PR addresses a handful of scenarios where the language server wasn't behaving well in actual usage.

  • Any unhandled errors thrown within GlintLanguageServer are caught and logged, and a sensible "no answer" response is sent instead
  • @glimmer/syntax gives entirely different errors based on whether the syntax problem came from the handlebars parser or the secondary HTML layer. We now no longer choke on the latter type, and make a best-effort attempt to extract the error location in that scenario as well.
  • We no longer spew Internal error: offset out of bounds when an LSP request comes in on a template file with syntax errors
  • We no longer swallow zero-length transformed spans if the original span was also zero-length (this matters in TS 4.3 because they treat module definitions as an empty span at the start of the document instead of as the entire document like in <= 4.2)

I think this hits all the known crash points we've run into so far, though I'm sure there are others lurking in slightly less obvious corners.

@dfreeman dfreeman added the bug Something isn't working label Mar 2, 2021
@dfreeman dfreeman changed the title Log errors instead of crashing the language server More robust error handling in the language server Mar 2, 2021
@dfreeman dfreeman merged commit 33ef9cc into master Mar 3, 2021
@dfreeman dfreeman deleted the handle-errors branch March 3, 2021 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant