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: setting up workspace and get code actions hanging when go.mod contains versions that no longer exist #46859

Closed
upsampled opened this issue Jun 21, 2021 · 6 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

@upsampled
Copy link

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go from the VS Code integrated terminal.
    go version go1.16.5 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
 ~/go/bin/gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.7.0
    golang.org/x/tools/gopls@v0.7.0 h1:JQBHW81Gsyim6iDjUwGoPeSpXrSqwen3isPJLfDfaYU=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/sys@v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
    golang.org/x/tools@v0.1.3-0.20210608163600-9ed039809d4c h1:Pv9gNyJFYVdpUAVZYJ1BDSU4eGgXQ+0f3DIGAdolO5s=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.2.0 h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
    mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.57.1
507ce72a4466fbb27b715c3722558bb15afa9f48
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    v0.26.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
   gopkgs: /home/liam/go/bin/gopkgs installed
   go-outline: /home/liam/go/bin/go-outline installed
   gotests: /home/liam/go/bin/gotests installed
   gomodifytags: /home/liam/go/bin/gomodifytags installed
   impl: /home/liam/go/bin/impl installed
   goplay: /home/liam/go/bin/goplay installed
   dlv: /home/liam/go/bin/dlv installed
   dlv-dap: /home/liam/go/bin/dlv-dap installed
   staticcheck: /home/liam/go/bin/staticcheck installed
   gopls: /home/liam/go/bin/gopls installed

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

    "go.toolsManagement.autoUpdate": true,
    "go.languageServerFlags": [
        "-rpc.trace"
      ]

Describe the bug

When opened VS Code displays Setting up workspace: Loading packages... Source: Go (extension)
When trying to save the 'finding actions from go' hangs

Steps to reproduce the behavior:

  1. Open VS Code (see the setting up issue)
  2. Edit a file and save (see getting code action error)

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

[Trace - 12:24:29.575 PM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}


[Trace - 12:24:29.581 PM] Sending notification '$/setTrace'.
Params: {"value":"off"}


[Trace - 12:24:29.584 PM] Sending response 'window/workDoneProgress/create - (1)' in 9ms.
Result: 


[Trace - 12:24:29.585 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}


[Trace - 12:24:29.585 PM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"<WORKDIRPATH>","section":"gopls"}]}


[Trace - 12:24:29.594 PM] Sending response 'workspace/configuration - (2)' in 8ms.
Result: [{"build.buildFlags":["-tags","pain"]}]


[Trace - 12:24:29.626 PM] Sending notification '$/setTrace'.
Params: {"value":"off"}


[Trace - 12:24:29.645 PM] Sending request 'textDocument/codeAction - (1)'.
Params: {"textDocument":{"uri":"<FILEPATH>"},"range":{"start":{"line":237,"character":38},"end":{"line":237,"character":38}},"context":{"diagnostics":[]}}


[Trace - 12:24:29.646 PM] Sending request 'textDocument/documentLink - (2)'.
Params: {"textDocument":{"uri":"<FILEPATH>"}}


[Trace - 12:24:30.049 PM] Sending request 'textDocument/documentLink - (3)'.
Params: {"textDocument":{"uri":"<FILEPATH>"}}


[Trace - 12:24:30.050 PM] Sending request 'textDocument/foldingRange - (4)'.
Params: {"textDocument":{"uri":"<FILEPATH>"}}


[Trace - 12:24:30.053 PM] Sending request 'textDocument/codeLens - (5)'.
Params: {"textDocument":{"uri":"<FILEPATH>"}}


[Trace - 12:24:30.091 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2021/06/21 12:24:30 go env for <WORKDIR>\n(root<WORKDIR>)\n(go version go version go1.16.5 linux/amd64)\n(valid build configuration = true)\n(build flags: [-tags pain])\nGOINSECURE=\nGONOSUMDB=<ORG>\nGOPATH=/home/USERNAME/go\nGO111MODULE=\nGOMODCACHE=/home/USERNAME/go/pkg/mod\nGOROOT=/usr/local/go\nGOSUMDB=sum.golang.org\nGOCACHE=/home/USERNAME/.cache/go-build\nGOFLAGS=\nGOMOD=<WORKDIR>\nGOPROXY=https://proxy.golang.org,direct\nGONOPROXY=<ORGREPO>\nGOPRIVATE=<ORGREPO>\n\n"}


[Info  - 12:24:30 PM] 2021/06/21 12:24:30 go env for <WORKDIR>
(root <WORKDIR>)
(go version go version go1.16.5 linux/amd64)
(valid build configuration = true)
(build flags: [-tags pain])
GOINSECURE=
GONOSUMDB=<ORGREPO>
GOPATH=/home/USERNAME/go
GO111MODULE=
GOMODCACHE=/home/USERNAME/go/pkg/mod
GOROOT=/usr/local/go
GOSUMDB=sum.golang.org
GOCACHE=/home/USERNAME/.cache/go-build
GOFLAGS=
GOMOD=<WORKDIR>/go.mod
GOPROXY=https://proxy.golang.org,direct
GONOPROXY=b<ORGREPO>
GOPRIVATE=<ORGREPO>


[Trace - 12:24:30.143 PM] Sending notification '$/cancelRequest'.
Params: {"id":5}


[Trace - 12:24:30.366 PM] Sending request 'textDocument/codeLens - (6)'.
Params: {"textDocument":{"uri":"<FILEPATH>"}}


[Trace - 12:24:30.936 PM] Sending notification '$/cancelRequest'.
Params: {"id":1}


[Trace - 12:24:30.937 PM] Sending request 'textDocument/codeAction - (7)'.
Params: {"textDocument":{"uri":"<FILEPATH>"},"range":{"start":{"line":237,"character":38},"end":{"line":237,"character":38}},"context":{"diagnostics":[]}}


[Trace - 12:24:30.937 PM] Sending request 'textDocument/documentSymbol - (8)'.
Params: {"textDocument":{"uri":"<FILEPATH>"}}


[Trace - 12:25:26.604 PM] Sending notification '$/cancelRequest'.
Params: {"id":6}


[Trace - 12:25:26.604 PM] Sending request 'textDocument/codeLens - (9)'.
Params: {"textDocument":{"uri":"<FILEPATH>"}}
...
[Trace - 13:03:39.915 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/06/21 13:03:39 failed to compute document links: context deadline exceeded\n\tURI=<FILE>\n"}


[Error - Received] 13:03:39.915 PM golang/vscode-go#4 JSON RPC cancelled


[Error - Received] 13:03:39.915 PM golang/vscode-go#3 JSON RPC cancelled


[Error - Received] 13:03:39.915 PM golang/vscode-go#5 JSON RPC cancelled


[Error - Received] 13:03:39.915 PM golang/vscode-go#6 JSON RPC cancelled


[Error - Received] 13:03:39.915 PM golang/vscode-go#7 JSON RPC cancelled


[Error - Received] 13:03:39.915 PM golang/vscode-go#8 JSON RPC cancelled


[Error - Received] 13:03:39.915 PM golang/vscode-go#9 JSON RPC cancelled


[Error - 1:03:39 PM] 2021/06/21 13:03:39 failed to compute document links: context deadline exceeded
	URI=<FILE>

[Trace - 13:03:40.166 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/06/21 13:03:40 diagnosing go.mod: context deadline exceeded\n"}


[Error - 1:03:40 PM] 2021/06/21 13:03:40 diagnosing go.mod: context deadline exceeded

[Trace - 13:03:40.179 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2021/06/21 13:03:40 errors loading workspace: context deadline exceeded\n\tsnapshot=1\n\tdirectory=<WORKDIR>\n"}


[Error - 1:03:40 PM] 2021/06/21 13:03:40 errors loading workspace: context deadline exceeded
	snapshot=1
	directory=<WORKDIR>

@upsampled
Copy link
Author

it looks like go list is hanging

@hyangah
Copy link
Contributor

hyangah commented Jun 21, 2021

Does go build -tags pain ./... from the with the go env gopls is seeing work?

go env for <WORKDIR>
(root <WORKDIR>)
(go version go version go1.16.5 linux/amd64)
(valid build configuration = true)
(build flags: [-tags pain])
GOINSECURE=
GONOSUMDB=<ORGREPO>
GOPATH=/home/USERNAME/go
GO111MODULE=
GOMODCACHE=/home/USERNAME/go/pkg/mod
GOROOT=/usr/local/go
GOSUMDB=sum.golang.org
GOCACHE=/home/USERNAME/.cache/go-build
GOFLAGS=
GOMOD=<WORKDIR>/go.mod
GOPROXY=https://proxy.golang.org,direct
GONOPROXY=b<ORGREPO>
GOPRIVATE=<ORGREPO>

ps. I assume GONOPROXY=b<ORGREPO> above is just a typo while you were trying to hide org repo name with ORGREPO. Am I right?

@upsampled
Copy link
Author

upsampled commented Jun 21, 2021

Problem was isolated to the go.mod file having a module version with a no longer accessible git commit hash.

This caused go list to hang which caused Setting up workspace: Loading packages... Source: Go (extension) to display while it was hanging.

@hyangah
Copy link
Contributor

hyangah commented Jun 21, 2021

Thanks @upsampled and good to hear that you figure it out on your own.

We think there is still room for improvement in gopls - i.e. reducing the initial package loading timeout (currently 15min?) and surfacing a bit more details in the progress notification. I will reopen and transfer to the gopls issue tracker for more discussion.

@hyangah hyangah reopened this Jun 21, 2021
@hyangah hyangah changed the title Setting up workspace and get code actions hanging x/tools/gopls: setting up workspace and get code actions hanging when go.mod contains versions that no longer exist Jun 21, 2021
@hyangah hyangah transferred this issue from golang/vscode-go Jun 21, 2021
@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 Jun 21, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jun 21, 2021
@upsampled
Copy link
Author

@hyangah I agree, the following would have greatly sped up my debug time:

  1. As you mentioned, reducing the default timeout
  2. Reporting the command that was being run both during execution and on failure. I only found go list was the command on a lucky syntax highlight in go.mod.
  3. If possible, report actions that are being blocked by other actions (IE; the saving a file action looked like it was being blocked by the go list action).

@suzmue suzmue modified the milestones: Unreleased, gopls/unplanned Jun 21, 2021
@stamblerre stamblerre self-assigned this Jun 21, 2021
@gopherbot
Copy link

Change https://golang.org/cl/330969 mentions this issue: internal/lsp/cache: treat load timeouts as critical errors

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

5 participants