golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.87k stars 750 forks source link

gopls: connection to server is erroring.Shuting down server. #3027

Open pengkou opened 11 months ago

pengkou commented 11 months ago

Type: Bug

[Error - 6:12:17 PM] Client gopls: connection to server is erroring. Shutting down server. [Error - 6:12:17 PM] Stopping server failed Error: Client is not running and can't be stopped. It's current state is: starting at GoLanguageClient.shutdown (/root/.vscode-server/extensions/golang.go-0.39.1/dist/goMain.js:15406:17) at GoLanguageClient.stop (/root/.vscode-server/extensions/golang.go-0.39.1/dist/goMain.js:15383:21) at GoLanguageClient.stop (/root/.vscode-server/extensions/golang.go-0.39.1/dist/goMain.js:17843:22) at GoLanguageClient.handleConnectionError (/root/.vscode-server/extensions/golang.go-0.39.1/dist/goMain.js:15624:16) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Extension version: 0.39.1 VS Code version: Code 1.83.1 (f1b07bd25dfad64b0167beb15359ae573aecd2cc, 2023-10-10T23:46:55.789Z) OS version: Darwin x64 22.6.0 Modes: Remote OS version: Linux x64 3.10.107-1-tlinux2_kvm_guest-0049

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2600)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|2, 2, 2| |Memory (System)|16.00GB (0.20GB free)| |Process Argv|--crash-reporter-id 7749a106-8b6f-46b8-ab3e-47b8cb87cc62| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: 9.134.163.170| |OS|Linux x64 3.10.107-1-tlinux2_kvm_guest-0049| |CPUs|AMD EPYC 7K62 48-Core Processor (8 x 2595)| |Memory (System)|15.42GB (14.44GB free)| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 py29gd2263:30856252 vsclangdc:30486549 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30695312 azure-dev_surveyone:30548225 2e4cg342:30602488 f6dab269:30613381 showlangstatbar:30737416 962ge761:30841074 03d35959:30757346 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30866567 pythonnoceb:30805159 copilotsettingt:30859503 synctok:30869157 dsvsc013:30795093 dsvsc014:30804076 dsvsc015:30845448 pythontestfixtcf:30871695 pythonregdiag2:30871582 pyreplss1:30865275 pythoncet0:30874138 2e7ec940:30870395 pythontbext0:30864172 ```
findleyr commented 11 months ago

Hi, thanks for the report. Could you please share the output of gopls version?

Can you please also share the log you see in the gopls output channel and tell us when you observed this popup (e.g. I was updating gopls, I just opened the vscode, I did refactoring, ...)? Screen Shot 2021-01-27 at 2 53 49 PM

pengkou commented 11 months ago

企业微信截图_00ecdf14-2b19-46bb-bf15-8a8ac491e9ca

I observed this popup when I just opened the vscode.

pengkou commented 11 months ago

it works well before, this issue occurs just from the Monday of this weak.

findleyr commented 11 months ago

Can you please share the output of gopls version?

pengkou commented 11 months ago

golang.org/x/tools/gopls v0.14.1 golang.org/x/tools/gopls@v0.14.1 h1:XaTETpi7Q67XO8nftquJitcx+9c2bPclO8Kz2sBVvec=

hyangah commented 11 months ago

Thanks @jiangxiaPeter Are you still experiencing the issue?

pengkou commented 11 months ago

Can you please share the log entries before what's shown in your screenshot? Connection to server was erroring, and we need to learn what that is.

log entries in the screenshot is all that in the gopls output channel.

output of gopls -v version. (sorry -v was missing)

Build info

golang.org/x/tools/gopls v0.14.1 golang.org/x/tools/gopls@v0.14.1 h1:XaTETpi7Q67XO8nftquJitcx+9c2bPclO8Kz2sBVvec= github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/mod@v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= golang.org/x/sync@v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= golang.org/x/sys@v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/telemetry@v0.0.0-20231011160506-788d5629a052 h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y= golang.org/x/text@v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/tools@v0.14.1-0.20231026192422-8b5abd452b28 h1:5YgdZAe2w0x3Xrjv0+GXrI0jvm7qCQK/ySGFfiEHMfU= golang.org/x/vuln@v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc= go: go1.18

pengkou commented 11 months ago

The issue continues to exist now

hyangah commented 11 months ago

Thanks.

The error logs seem to indicate the LSP client couldn't establish connection at all. (this confusing error message - trying to stop a server that fails to start... - is under discussion https://github.com/microsoft/vscode-languageserver-node/issues/1307)

I think a couple of possibilities:

Daemon mode setup From a terminal, start the daemon on port 37374.

gopls -listen=:37374 -logfile=auto -debug=:0 -vv

The following VS Code setting will make the extension starts gopls in client mode.

 "go.languageServerFlags": ["-remote=:37374", "-logfile=auto", "-rpc.trace"]

See if the daemon receives connection, or crashes.

We've also seen cases where remote host environment is a problem (e.g. https://github.com/golang/vscode-go/issues/2986 even though this specific case seems to cause to crash the entire extension host :-(). So, would be also helpful to check if the same vscode/vscode-go/gopls/go causes the same issue on local dev setup.

pengkou commented 11 months ago

Try if rolling back to gopls v0.13.2 helps

I am trying by go get command go get golang.org/x/tools/gopls@v0.13.2, but it remains v0.14.1.

Try gopls daemon mode setup - if gopls process crashes for some reason, that may be visible from the terminal where the daemon mode gopls runs.

root     17598  0.0  0.1 1144640 16220 pts/6   Sl+  09:34   0:00 gopls -listen=:37374 -logfile=auto -debug=:0 -vv
root     19420  0.1  0.0 1153092 13712 ?       Sl   09:36   0:00 /root/go/bin/gopls -mode=stdio -remote=:37374 -logfile=auto -rpc.trace

Nothing seems wrong, log entries on the terminal is:

gopls -listen=:37374 -logfile=auto -debug=:0 -vv
serve.go:443: debug server listening at http://localhost:46563
serve.go:132: Gopls daemon: listening on tcp network, address :37374...

lsprpc.go:106: Session 1: connected
lsprpc.go:484: Session 1: got handshake. Logfile: "/tmp/gopls-19420.log", Debug addr: ""

gopls-19420.log

So, would be also helpful to check if the same vscode/vscode-go/gopls/go causes the same issue on local dev setup.

It works well on my local mac machine with gopls v0.14.1

hyangah commented 11 months ago

To install gopls v0.13.2 use go install golang.org/x/tools/gopls@v0.13.2. (not go get). And restart window.

But, given that the client gopls (process 19420) claims it sent messages to the LSP client (vscode), I am more leaning towards the culprit is not in gopls.

If you enable the client side logging "go.trace.server": "verbose", you will be able to see more logging on the client-side output channel (name 'gopls'). Are there any trace of messages (initialize response) in the channel?

Before reaching out to the vscode team for help, you may try a couple of other things

pengkou commented 11 months ago

No more log found after client side logging enabled.

Restarting the remote vscode server and Restarting the remote machine does not work too.

pengkou commented 11 months ago

There will be some cost for me to migrate the remote machine, I will try later.

jwbda commented 2 months ago

Same problem, anything new?