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

x/tools/gopls: client not receiving messages from server #46694

Closed
stamblerre opened this issue Jun 10, 2021 · 7 comments
Closed

x/tools/gopls: client not receiving messages from server #46694

stamblerre opened this issue Jun 10, 2021 · 7 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Soon This needs to be done soon. (regressions, serious bugs, outages) Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@stamblerre
Copy link
Contributor

First reported on Slack.

(From 2 different runs)
Client side: https://gophers.slack.com/files/T029RQSE6/F024HF0KRQE?origin_team=T029RQSE6.
Server side: https://gophers.slack.com/files/T029RQSE6/F024HECSV7Y?origin_team=T029RQSE6.

The next step in investigation is to log jsonrpc2 bytes to files to understand what is actually happening over the wire.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jun 10, 2021
@stamblerre stamblerre self-assigned this Jun 10, 2021
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jun 10, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jun 10, 2021
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.7.1 Jun 10, 2021
@stamblerre stamblerre added the Soon This needs to be done soon. (regressions, serious bugs, outages) label Jun 10, 2021
@jvoll
Copy link

jvoll commented Jun 11, 2021

After following the instructions posted: https://gophers.slack.com/archives/C2B4L99RS/p1623424302142500

I have the following logs:
gopls-server.txt
gopls.txt
log-extension-host.txt

None of the other log outputs in VS code seem to have anything interesting, most are empty or just a few lines.

This is the entire project on one screen:
image

I opened VS Code from my terminal: cd test-project; code .

@stamblerre
Copy link
Contributor Author

From those instructions--do you have the trace.log file that should be generated in your test project?

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 11, 2021
@stamblerre
Copy link
Contributor Author

And one more thing to try after this, is to delete the wrapper script and the "go.alternateTools" setting and instead add the following to your settings:

"go.languageServerFlags": [
	"-remote=auto",
	"-rpc.trace",
]

If gopls starts working, then the issue is that we are writing something that doesn't fit the protocol to stdout.

@jvoll
Copy link

jvoll commented Jun 11, 2021

Ah, I had forgotten to make the script an executable and therefore wasn't getting trace.log. I've fixed that now, here's the file. You can ignore the "CANCEL"'s in there (or just know that it means that the Go context got cancelled!). At one point recently we were debugging something and added a `fmt.Println("CANCEL") on context cancel and didn't manage to clean it up (it's buried somewhere deep and it wasn't worth tracking down).
trace.log

I also tried adding the '"-remote=auto",' in there and it seems to somewhat alleviate the problem? It's a bit strange, I can still reproduce the loading packages sometimes but not 100% of the time. It seems to help most on the smaller test projects than on the big project (I haven't got the big project working at all yet) but my data points are fairly limited and it's hard to say for sure.

@findleyr
Copy link
Contributor

At one point recently we were debugging something and added a `fmt.Println("CANCEL")

That's the problem. Writing CANCEL to stdout breaks the jsonrpc2 stream.

@findleyr
Copy link
Contributor

I also tried adding the '"-remote=auto",' in there and it seems to somewhat alleviate the problem? It's a bit strange, I can still reproduce the loading packages sometimes but not 100% of the time.

I'm guessing that even when operating as a thin forwarder, gopls can hit some context cancellations.

Whelp, mystery solved. Please re-build gopls with a clean GOROOT.

@jvoll
Copy link

jvoll commented Jun 11, 2021

Oh wow! Thank you so much for your help, that indeed fixed the problem!

I cleaned up cached modules (go clean --modcache) and some other stuff and rebuilt gopls and some other go packages on my system and that fixed things up.

Sorry for the weird issue and thanks for your time @stamblerre and @findleyr!

@golang golang locked and limited conversation to collaborators Jun 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Soon This needs to be done soon. (regressions, serious bugs, outages) Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants