-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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 mbc documents properly #9151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tried this out with VS Code Canary 0.0.6 (debug build) in https://github.com/lucacasonato/deno_s3, but after a few seconds of everything working fine (maybe before the extension loads? extension & lsp are loaded at this point, and is responding to requests) the whole LSP becomes unresponsive and the deno lsp
process pins my CPU. This can be 1. seen by the laptop fan going into overdrive, and 2. the hover not responding anymore.
After about 3 minutes everything calms down again, and the LSP becomes responsive again. Something is going on here, because deno_s3
is not a very large repo.
It seems you can get it to reliably happen by hovering on a imported item in an import statement. |
@lucacasonato it feels like it is some sort of deadlock issue with the hover stuff... I am experiencing a similar problem. I am looking at it now. |
@ry I had unit tests for the issues I encountered that went above the other PR, but I have added an integration test that is even more in depth that what was in the PR. It opens the document, edits it at a point where we had problems before and then hovers in another location and validates the hover reflects the edit properly. @lucacasonato I believe I have fixed the dead-lock issue. We were fetching all line index async, even when ones for open documents should be retrieved sync, which meant we ran into a dead-lock issue between handling the request and tsc, which both need access to line indexes. |
Awesome. That hover deadlock seems to be fixed. I have found a new issue though (happens when hovering in
I also encountered another deadlock that occurred after I tried out some commands, and then did |
@lucacasonato I know what the hover problem is... I forgot we can have assets open. I will take a look at |
I've fixed the problem with the assets, but I have tried a couple other projects and on a debug build I can pretty easily get it to hang. I have a theory that something before was preventing us being "thread bound" with tsc, but now I think we might be trying to send multiple requests into tsc at the same time, causing hangs. Either way, I need to add some instrumentation to see where we are really hanging. |
It would be very nice if we could reproduce this hang in the tests before we fix it. @kitsonk Maybe we can pair program this later today |
I can try... We need to narrow down where it is exactly happening so it can be reliably reproduced... Right now it requires clicking around quickly in an editor. Sometimes it just hangs for 10 seconds or so, sometimes I lose patience. |
Thanks to pairing with @ry I think I have discovered the issue and fixed it. It is rather complex:
So I think we are going to have to revert to dissimilar and know that it will not handle certain documents properly (though it is really an edge case that will cause the problem) and figure out how to resolve the dissimilar issue. I think I will be able to recreate a test failure now by editing a large document and then requesting hovers on it. Other points we discussed:
|
LGTM - I defer to @lucacasonato for final review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally, and everything works without hangs now. Great job! I think this abstraction is a lot simpler, and more useful.
LGTM
Resolves #9018
This PR refactors the way in memory documents are handled and changed, specifically properly handling the way vscode and tsc handle text positions in documents which now properly handles unicode characters which have > 2 bytes for encoding. It also consolidates the way that TypeScript diagnostics are collected. There are other minor improvements and changes as well.