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
Milestone

Comments

@rchl
Copy link

@rchl 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 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

@stamblerre stamblerre commented Aug 17, 2020

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 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

@gopherbot gopherbot commented Aug 19, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.