-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: "addView called before server initialized" #57459
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
Comments
I can repro, and will investigate. Thank you for the script. My guess is that it is the lack of workspace folders that causes this script to fail, but I'm surprised that this wouldn't have been reported before now (I verified that this bug exists at least back to [email protected]. How did you first encounter this? |
I encounter the same bug with a LSP plugin for the vis editor, I maintain. But since I had no easy reproducer I did not open an issue yet. |
Ok, I investigated and the bug is actually that the initialized notification is never processed, because parsing params fails as a result of the params field missing. If you add This is a bug in gopls, as per the jsonrpc2 spec params may be omitted. There is also missing logging that would surface this parse error. CC @pjweinb, who maintains our protocol package. I think we need to:
|
Change https://go.dev/cl/548857 mentions this issue: |
This change makes the request.params object or array optional, as specified by JSONRPC and LSP. Also: - move the DocumentURI, URI declarations out of the generator. - fix nuisance //go:generate command leaking out of a test. Fixes golang/go#57459 Change-Id: Id31e3a306533d428284cad008d092da1a2fc06d4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/548857 Reviewed-by: Robert Findley <[email protected]> Reviewed-by: Peter Weinberger <[email protected]> Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
gopls version
What did you do?
Here is a simple "virtual" LSP client:
What did you expect to see?
This is (as far as I'm aware) a perfectly valid series of LSP requests. (By the time the
initialized
notification is sent,the server has already sent the
initialize
response.)There should be no problems for gopls here.
What did you see instead?
After the 3rd message, gopls gives the client these notifications:
Using
workspaceFolders
instead ofrootUri
gives the exact same result (in any case both must be handled by an LSP server).Waiting for more time after sending
initialized
does not resolve the issue.Sending any more requests after this gives back the cryptic response:
with the non-existent error code 0.
The text was updated successfully, but these errors were encountered: