Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Frequent pop-up when saving with "Getting code actions: Go, Go, ..." #3179

Closed
stamblerre opened this issue Apr 15, 2020 · 8 comments
Closed
Labels
upstream-gopls Issue for gopls

Comments

@stamblerre
Copy link
Contributor

If you encounter this issue, please try the following steps to troubleshoot:

  1. Check your other installed extensions. Go Group Imports and Spell Right have both been identified as causing slow saves.
  2. Your workspace may have errors which are causing gopls to be slow. Capture your gopls logs and post them here (if you're able to share them). Detailed gopls logs are best, so please add the -rpc.trace to go.languageServerFlags.

For reference, this bug is referring to an error that appears like this:
image

This issue consolidates #3063, #3105, #3141, #3170, etc.

@hairyhenderson
Copy link

@stamblerre I was seeing this dialog for a little bit, but now it's not popping up at all and gopls seems to be ... napping?

I'm seeing this error in the logs:

[Error - 5:05:20 p.m.] 2020/04/16 17:05:20 failed to load workspace packages, skipping diagnostics: github.com/myorg/myproject/api/model has no metadata
	snapshot=10087
	directory=file:///Users/hairyhenderson/go/src/github.com/myorg/myproject

I did delete the api/model directory (with a git rm command in a shell), but it appears something went out of sync and thinks that directory is still around?

@stamblerre
Copy link
Contributor Author

That's definitely possible - thanks for the report @hairyhenderson. I'll add a regression test for this case (golang/go#38407 (comment)). Ctrl + Shift + P -> Go: Restart Language Server should fix it temporarily.

@hairyhenderson
Copy link

@stamblerre thanks! That's a super-helpful shortcut! I usually just ps -eaf | grep gopls and kill one at random until the right one restarts 😂

@Wisgon
Copy link

Wisgon commented May 7, 2020

That's definitely possible - thanks for the report @hairyhenderson. I'll add a regression test for this case (golang/go#38407 (comment)). Ctrl + Shift + P -> Go: Restart Language Server should fix it temporarily.

It doesn't work for me. When I Ctrl + Shift + P -> Go: Restart Language Server , Nothing happen and there is no code hintting any more, though I wait a long time. Finally I have to restart vscode.

By the way, I got gopls error message:

[Info  - 上午11:41:17] 2020/05/07 11:41:17 go/packages.Load
	snapshot=0
	directory=D:\Documents\my_projects\learn_micro
	query=[./... builtin]
	packages=17
[Error - 上午11:41:18] Request textDocument/foldingRange failed.
  Message: invalid pos
  Code: 0 
[Error - 上午11:41:18] 2020/05/07 11:41:18 DocumentSymbols failed: invalid pos
	URI=file:///D:/Documents/my_projects/learn_micro/grpcConsulDemo/simpleClient_test.go
[Error - 上午11:57:02] Request textDocument/foldingRange failed.
  Message: invalid pos
  Code: 0 
[Error - 上午11:57:02] 2020/05/07 11:57:02 DocumentSymbols failed: invalid pos
	URI=file:///D:/Documents/my_projects/learn_micro/grpcConsulDemo/simpleClient_test.go
[Error - 上午11:57:02] Request textDocument/codeAction failed.
  Message: computing fix edits: D:\Documents\my_projects\learn_micro\grpcConsulDemo\simpleClient_test.go:16:6: expected operand, found ',' (and 9 more errors)
  Code: 0 
[Error - 上午11:57:02] Request textDocument/codeAction failed.
  Message: computing fix edits: D:\Documents\my_projects\learn_micro\grpcConsulDemo\simpleClient_test.go:16:6: expected operand, found ',' (and 9 more errors)
  Code: 0 
[Error - 上午11:57:02] Request textDocument/formatting failed.
  Message: 16:6: expected operand, found ',' (and 2 more errors)
  Code: 0 
[Error - 上午11:57:02] Request textDocument/codeAction failed.
  Message: computing fix edits: D:\Documents\my_projects\learn_micro\grpcConsulDemo\simpleClient_test.go:16:6: expected operand, found ',' (and 9 more errors)
  Code: 0 

I know I have syntax error in my code, that not the key, the key point is, the Saving 'main.go': Getting code actions from ''Go', 'Go'' (configure). takes too much time.

@stamblerre
Copy link
Contributor Author

@Wisgon: If you add

"go.languageServerFlags": [
  "-rpc.trace"
]

to your VS Code settings, it should give you more detailed information. However, if your project is very large / has a lot of dependencies, it's possible that something else is going wrong.

@bobheadxi
Copy link

bobheadxi commented May 15, 2020

Restarting the language server didn't do anything for me, but @onlyafly 's recommendation to downgrade the Go extension to 0.13.1 solved the issue completely

Things I tried:

  • restarting gopls
  • reinstalling vscode
  • reinstalling gopls, tools, etc.
  • downgrading VS code
  • downgrading gopls
  • downgrading a variety of other tools that would run on save

@stamblerre
Copy link
Contributor Author

@bobheadxi: This error usually starts happening when there is some misconfiguration or issue with gopls. Please take a look at the first comment on this issue (#3179 (comment)) for advice on how to troubleshoot this.

@stamblerre
Copy link
Contributor Author

Going to close this issue, as I haven't heard of many people encountering this recently.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream-gopls Issue for gopls
Projects
None yet
Development

No branches or pull requests

4 participants