Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

v0.20.0 works, v0.21.0 causes "Cannot get property 'get' of undefined" #1104

Closed
PatrickDuncan opened this issue Jan 20, 2021 · 10 comments
Closed
Assignees
Milestone

Comments

@PatrickDuncan
Copy link

PatrickDuncan commented Jan 20, 2021

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

  • Run go version to get version of Go
    • go version go1.14.3 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • Version: 1.52.1
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.21.0
  • Run go env to get the go development environment details
    • (Work machine)

Share the Go related settings you have added/edited

Default

Describe the bug

When I saw I get the Cannot get property 'get' of undefined, but it seems like the extension was partially doing its job still. v0.20.0 does not have the error at all.

Steps to reproduce the behavior:

  1. Use v0.21.0 and save a .go file on macOS
@hyangah
Copy link
Contributor

hyangah commented Jan 20, 2021

@PatrickDuncan Thanks for the report - do you mind sharing the full exception log? I guess the error message is either in the
View: Toggle Output -> Log(Extension Host) or
Developer: View Developer Tools -> Console tab

@hyangah
Copy link
Contributor

hyangah commented Jan 20, 2021

Oh, nevermind. I reproduced the issue. :-(

How to reproduce: disable the language server, which will activate the default build/vet checks.

TypeError: Cannot read property 'get' of undefined
	at /Users/hakim/projects/google/vscode-go/dist/goMain.js:112401:94
	at Map.forEach (<anonymous>)
	at Object.handleDiagnosticErrors (/Users/hakim/projects/google/vscode-go/dist/goMain.js:112387:19)
	at /Users/hakim/projects/google/vscode-go/dist/goMain.js:107553:20
	at Array.forEach (<anonymous>)
	at /Users/hakim/projects/google/vscode-go/dist/goMain.js:107552:17 {stack: 'TypeError: Cannot read property 'get' of unde…cts/google/vscode-go/dist/goMain.js:107552:17', message: 'Cannot read property 'get' of undefined'}

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/285092 mentions this issue: src/util.ts: handle inactive languageClient

@kjbass
Copy link

kjbass commented Jan 20, 2021

I'm encountering the same issue myself -- I might be a little dense towards the end of the day, but could you clarify if there is a workaround for this currently?

EDIT: I see now, setting "go.useLanguageServer": true, solves this, if anyone else runs into it.

@hyangah
Copy link
Contributor

hyangah commented Jan 20, 2021

Thanks @kjbass for sharing the workaround. That's what I'd recommend - we plan to enable the language server by default next week so this is a good time to test 😅

If enabling the language server isn't an option, please try the older version (0.20.0)
Go to the extension view (Ctrl+Shift+X or Cmd+Shift+X) -> select Go -> select the gear icon -> select "Install another version" -> choose the old version

I will try to publish the patch as soon as it is reviewed. Sorry for the inconvenience.

@shotgunwilly
Copy link

I had the same issue running on Windows 10. Went back to version v0.20.2 and is working again.

@kelleyau
Copy link

kelleyau commented Jan 21, 2021

I have this problem on OSX 11.1
Go version:
go version go1.15.7 darwin/amd64

Vscode version:
1.52.1

Go extension version:
v0.21.0

I also tried adding the languageserver to my settings via the sugggested workaround and that does not work for me unfortunately:

EDIT: Thanks to @BatmanAoD I was able to get rid of the error by running "Go: Install/Update Tools" and selecting all the packages and re-installing them (CMD + SHIFT + P)

@BatmanAoD
Copy link

I had the same issue, I think. I also had other weird errors, such as:

Cannot activate the 'Go Coverage Viewer' extension because it depends on an unknown 'ms-vscode.go' extension .

After some fruitless searching (and following the troubleshooting guide), I eventually discovered that my gopls was at version 0.5.5. VSCode was unable to update the tool for me (unfortunately I can't remember the error message), but manually updating to the latest (0.6.4) seems to have fixed things.

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/285255 mentions this issue: [release] src/util.ts: handle inactive languageClient

gopherbot pushed a commit that referenced this issue Jan 21, 2021
goLanguageServer's languageClient can be a valid language client,
but isn't started yet. So, check if the diagnostic info is
available and if there is any diagnostic for the given file uri
before trying to start deduping.

This addresses the exception thrown when the extension tries to
access the undefined diagnostics.

Another issue is the buildLanguageClient currently creates a non-nill
languageClient object even when the language client doesn't need to
be enabled. But that change is too subtle to be included in
a patch release, so we don't address here.

Fixes #1104

Change-Id: Id923719462b68972a79e3f7c32f54edba7462e46
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/285092
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
(cherry picked from commit 7f56895)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/285255
@hyangah
Copy link
Contributor

hyangah commented Jan 21, 2021

v0.21.1 is now released. Thank you again for reporting the issue and sharing workarounds!

@golang golang locked and limited conversation to collaborators Jan 21, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

7 participants