Skip to content

x/tools/gopls: do not block on initial workspace/configuration request #54559

@bcmills

Description

@bcmills
~/x/tools/gopls$ go version -m $(which gopls)
/usr/local/google/home/bcmills/bin/gopls: devel go1.20-6001c043dc Fri Aug 19 03:32:27 2022 +0000
        path    golang.org/x/tools/gopls
        mod     golang.org/x/tools/gopls        v0.9.4  h1:YhHOxVi++ILnY+QnH9FGtRKZZrunSaR7OW8/dCp7bBk=
        dep     github.com/BurntSushi/toml      v1.2.0  h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
        dep     github.com/google/go-cmp        v0.5.8  h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
        dep     github.com/sergi/go-diff        v1.1.0  h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
        dep     golang.org/x/exp/typeparams     v0.0.0-20220722155223-a9213eeb770e      h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
        dep     golang.org/x/mod        v0.6.0-dev.0.20220419223038-86c51ed26bb4        h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
        dep     golang.org/x/sync       v0.0.0-20220722155255-886fb9371eb4      h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
        dep     golang.org/x/sys        v0.0.0-20220722155257-8c9f86f7a55f      h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
        dep     golang.org/x/text       v0.3.7  h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
        dep     golang.org/x/tools      v0.1.13-0.20220812184215-3f9b119300de   h1:b68wxF4nfQjj1XTRHtjVjCximbhAwjztuzDEFGU+n9o=
        dep     golang.org/x/vuln       v0.0.0-20220725105440-4151a5aca1df      h1:BkeW9/QJhcigekDUPS9N9bIb0v7gPKKmLYeczVAqr2s=
        dep     honnef.co/go/tools      v0.3.2  h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=
        dep     mvdan.cc/gofumpt        v0.3.1  h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
        dep     mvdan.cc/xurls/v2       v2.4.0  h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
        build   -compiler=gc
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v2

GNU Emacs 28.1
eglot built from source at joaotavora/eglot commit 000b7fd.

Does this issue reproduce with the latest release?

Yes.

What did you do?

Use gopls with eglot for a large stack of changes in the module at GOROOT/src/cmd.

What did you expect to see?

Responsive gopls actions via eglot.

What did you see instead?

M-x eglot-format-buffer frequently and consistently times out. On further investigation (details in joaotavora/eglot#587 (comment)), I found what appears to be a distributed deadlock.

  • gopls is blocking its responses pending a reply to its workspace/configuration request.
  • It appears that eglot is failing to process the workspace/configuration request because it is still awaiting a response for its own textDocument/documentSymbol request.

The LSP specification recommends that clients and servers be implemented asynchronously, so I believe that both programs are in some sense in the wrong here: eglot should not block on a response to its documentSymbol request, but neither should gopls block on a response to its configuration request.

Instead, gopls should either serve best-effort results for the documentSymbol request without more detailed configuration, or it should serve an explicit error in order to resolve any intervening requests from the client.

(I believe that joaotavora/eglot#587 tracks the corresponding bug on the eglot side.)

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions