Navigation Menu

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: returns with non-0 exit code on server restart / shutdown #40832

Closed
rchl opened this issue Aug 16, 2020 · 3 comments
Closed

x/tools/gopls: returns with non-0 exit code on server restart / shutdown #40832

rchl opened this issue Aug 16, 2020 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@rchl
Copy link

rchl commented Aug 16, 2020

What version of Go are you using (go version)?

$ go version
go1.14.5 darwin/amd64
gopls 0.4.4

Does this issue reproduce with the latest release?

Yes?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
(valid build configuration = false)
(build flags: [])
GOINSECURE=
GOPATH=/Users/me/go
GOROOT=/usr/local/Cellar/go/1.14.5/libexec
GO111MODULE=
GONOPROXY=
GOPROXY=https://proxy.golang.org,direct
GOSUMDB=sum.golang.org
GOCACHE=/Users/me/Library/Caches/go-build
GOMOD=
GOMODCACHE=
GONOSUMDB=
GOPRIVATE=
GOFLAGS=

What did you do?

  1. Open a go file in VSCode
  2. Trigger Go: Restart Language Server from the command palette

What did you expect to see?

In the go server logs, there should be no:

gopls: failed reading header line: EOF

message

What did you see instead?

I see the aforementioned message in the logs and the server is exiting with exit code 2.

I think the relevant code is here:
https://github.com/golang/tools/blob/cc40288be83943c50bf80a9702fb35bd5e580e8d/internal/jsonrpc2/stream.go#L110-L114
And the problem might be that it's not doing what the comment there says. The comment says:

// read the header, stop on the first empty line

but since the s.in.ReadString('\n') call is looking for a newline, I think it will return non-nil err when it sees an empty line. Thus we'll never get to the graceful, empty-line handling lower in the code.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 16, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 16, 2020
@stamblerre stamblerre changed the title x/tools/gopls Returns with non-0 exit code on server restart / shutdown x/tools/gopls: returns with non-0 exit code on server restart / shutdown Aug 17, 2020
@stamblerre
Copy link
Contributor

Thanks for the report! I haven't seen this issue before--are you able to consistently reproduce it when you restart the language server?

/cc @findleyr @ianthehat

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v.0.5.0 Aug 17, 2020
@rchl
Copy link
Author

rchl commented Aug 17, 2020

Yes. I can consistently reproduce it.

Note that I'm not a VSCode user. I'm using Sublime Text where non-zero exit code returned from the server triggers a "crash dialog" so that's why I've noticed it.

But as I've said, I've also reproduced this with VSCode (at least the same stderr message as I can't see the exit code in vscode).

@gopherbot
Copy link

Change https://golang.org/cl/249417 mentions this issue: internal/lsp/cmd: suppress EOF errors in serve

@golang golang locked and limited conversation to collaborators Aug 19, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants