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

Gopls crashed in vscode and couldn't create connection to server #2300

Closed
dle8 opened this issue Jun 22, 2022 · 5 comments
Closed

Gopls crashed in vscode and couldn't create connection to server #2300

dle8 opened this issue Jun 22, 2022 · 5 comments
Assignees
Milestone

Comments

@dle8
Copy link

dle8 commented Jun 22, 2022

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

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.18 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls master
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.68.1
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.34.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

Checking configured tools....
GOBIN: undefined
toolsGopath:
gopath: /Users/dungtuanle/go
GOROOT: /usr/local/go
PATH: /Users/dungtuanle/go/bin:/usr/local/git/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/go/bin

go:	/usr/local/go/bin/go: go version go1.18 darwin/amd64

gotests:	not installed
gomodifytags:	not installed
impl:	not installed
goplay:	not installed
dlv:	/Users/dungtuanle/go/bin/dlv	(version: v1.8.2 built with go: go1.18)
staticcheck:	not installed
gopls:	/Users/dungtuanle/go/bin/gopls	(version: (devel) built with go: go1.18)

go env
Workspace Folder (tools): /Users/dungtuanle/Desktop/tools
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dungtuanle/Library/Caches/go-build"
GOENV="/Users/dungtuanle/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/dungtuanle/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/dungtuanle/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dungtuanle/Desktop/tools/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nk/vc539lw93856mchxslm_qds000y1hm/T/go-build1615749012=/tmp/go-build -gno-record-gcc-switches -fno-common"

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.languageServerFlags": ["-remote=localhost:8091"],
    "gopls": {
        "ui.diagnostic.analyses": {
            "unusedparams": true
        }
    }
}

Describe the bug

Gopls couldn't create handshake when starting gopls server in vscode.

Steps to reproduce the behavior:

  1. Move to gopls directory and run go run . -listen=localhost:8091
  2. Restart language server with cmd+shift+p -> Go: Restart Language Server
  3. See error

Screenshots or recordings

image

@dle8 dle8 added this to the v0.34.1 milestone Jun 22, 2022
@hyangah
Copy link
Contributor

hyangah commented Jun 23, 2022

The problem occurred because in the user's setup, gopls was running in a forwarder mode, so startLanguageServer failed when the daemon mode gopls was not yet available. Unfortunately the exception wasn't handled. As a result, the go.languageserver.restart command registration didn't run.

@jamalc already addressed this missing exception handling & command registration ordering issue in https://go-review.googlesource.com/c/vscode-go/+/413424, and this change is available in today's Nightly release.

However, I noticed another issue -

Now we are prompting various error messages (including the prompt for filing an issue), which is still a regression from v0.33.x.

This needs fix.

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/414457 mentions this issue: src/language/goLanguageServer: remove redundant error popups from custom error handler

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/414456 mentions this issue: src/language/goLanguageServer: do not require gopls when language server is disabled

gopherbot pushed a commit that referenced this issue Jun 28, 2022
…ver is disabled

This fixes a bug that made the extension to look up the path to the gopls
binary when go.useLanguageServer is false. During the lookup, if the gopls wasn't
available, getLanguageServerToolPath eventually triggerred the missing tool prompt
and that was not appropriate. Return from buildLanguageServerConfig early
if we don't need the language server.

Updates #2300

Change-Id: I7572244350f953c8ce874086f4f5cbb45a7301af
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414456
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/414459 mentions this issue: [release] src/language/goLanguageServer: do not require gopls when language server is disabled

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/414460 mentions this issue: [release] src/language/goLanguageServer: remove redundant error popups from custom error handler

gopherbot pushed a commit that referenced this issue Jun 29, 2022
…nguage server is disabled

This fixes a bug that made the extension to look up the path to the gopls
binary when go.useLanguageServer is false. During the lookup, if the gopls wasn't
available, getLanguageServerToolPath eventually triggerred the missing tool prompt
and that was not appropriate. Return from buildLanguageServerConfig early
if we don't need the language server.

Updates #2300

Change-Id: I7572244350f953c8ce874086f4f5cbb45a7301af
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414456
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
(cherry picked from commit 4dd972e)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414459
gopherbot pushed a commit that referenced this issue Jun 29, 2022
…s from custom error handler

From vscode-languageclient v8.0.x (LSP 3.17), the language client reports the start
errors specially and surfaces them as user visible popups regardless revealOutputChannelOn
setting. Thus, our error popups are no longer necessary. Remove this.

When an error occurs during initialization, the connection to the server shuts
down which triggers the close handler. Previously, we suggested gopls issue
report from both initializationFailedHandler and errorHandler.closed handler.
That now results in two gopls issue report suggestions. Instead, stash the
initialization failure error, and handle the suggestion prompt from one place.

Note - in case of initializtion error, there is no point of retrying 5 times.

We also explicitly set the error & connection close handlers messages to empty
when requesting for continue/restart action, which will suppresses the default
error message popups.

While we are here, we improve the go status bar's language server state report
by updating it when the language server connection close is obeserved.

Updates microsoft/vscode-languageserver-node#1011
Fixes #2300

Change-Id: I8b20cf11ebb61ab474950440fc46ff23f7b0b826
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414457
Reviewed-by: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
(cherry picked from commit 99369b6)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/414460
Reviewed-by: Suzy Mueller <suzmue@golang.org>
@golang golang locked and limited conversation to collaborators Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants