golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.89k stars 17.65k forks source link

x/tools/gopls: crashes on gitlens files #40272

Closed leguminosa closed 4 years ago

leguminosa commented 4 years ago

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

Please attach the stack trace from the crash. A window with the error message should have popped up in the lower half of your screen. Please copy the stack trace from that window and paste it in this issue. panic: only file URIs are supported, got "gitlens" from "gitlens://7d8440e/home/nakama/workspace/tokopedia/rechargeapp?%7B%22path%22%3A%22%2Fhome%2Fnakama%2Fworkspace%2Ftokopedia%2Frechargeapp%22%2C%22ref%22%3A%227d8440ea48c374823952895e01eddef8328d2a3f%22%2C%22repoPath%22%3A%22%2Fhome%2Fnakama%2Fworkspace%2Ftokopedia%2Frechargeapp%22%7D" goroutine 90 [running]: golang.org/x/tools/internal/span.URI.Filename(...) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/span/uri.go:32 golang.org/x/tools/internal/lsp/cache.(*View).setBuildInformation(0xc0002d0000, 0xea7e80, 0xc00036e720, 0xc00032c000, 0x11a, 0xc0002ce000, 0x71, 0x71, 0x1, 0x5f5e100, ...) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/cache/view.go:746 +0x4ba golang.org/x/tools/internal/lsp/cache.(*Session).createView(0xc00017c600, 0xea7e80, 0xc00036e720, 0xc000322a20, 0x15, 0xc00032c000, 0x11a, 0x4000000000000000, 0x10101, 0xc0002fd788, ...) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/cache/session.go:157 +0x4d5 golang.org/x/tools/internal/lsp/cache.(*Session).NewView(0xc00017c600, 0xea7e80, 0xc00036e720, 0xc000322a20, 0x15, 0xc00032c000, 0x11a, 0x4000000000000000, 0x10101, 0xc0002fd788, ...) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/cache/session.go:108 +0x13c golang.org/x/tools/internal/lsp.(*Server).addView(0xc0002a7b80, 0xea7e80, 0xc00036e720, 0xc000322a20, 0x15, 0xc00032c000, 0x11a, 0xebbf00, 0xc0002d02c0, 0xebd640, ...) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/workspace.go:42 +0x1e4 golang.org/x/tools/internal/lsp.(*Server).addFolders(0xc0002a7b80, 0xea7e80, 0xc00036e720, 0xc0002a7e00, 0x2, 0x4) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/general.go:191 +0x184 golang.org/x/tools/internal/lsp.(*Server).initialized(0xc0002a7b80, 0xea7e80, 0xc00036e720, 0x1416e18, 0x0, 0x0) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/general.go:179 +0x280 golang.org/x/tools/internal/lsp.(*Server).Initialized(0xc0002a7b80, 0xea7e80, 0xc00036e720, 0x1416e18, 0x1416e18, 0x0) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/server_gen.go:112 +0x49 golang.org/x/tools/internal/lsp/protocol.serverDispatch(0xea7e80, 0xc00036e720, 0xec6080, 0xc0002a7b80, 0xc0001d3c50, 0x7fe93c608650, 0xc00036e6c0, 0x0, 0x0, 0xbfbc7a3def255911) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/protocol/tsserver.go:92 +0xa49 golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0xea7e80, 0xc00036e720, 0xc0001d3c50, 0x7fe93c608650, 0xc00036e6c0, 0x0, 0x0) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/protocol/protocol.go:62 +0xc0 golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0xea7e80, 0xc00036e720, 0xc0001d3c50, 0x7fe93c608650, 0xc00036e6c0, 0x0, 0x0) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/lsp/lsprpc/lsprpc.go:509 +0x43a golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0xea7e80, 0xc00036e720, 0xc000378340, 0x7fe93c608650, 0xc00036e6c0, 0x4074ef, 0xc000238658) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/jsonrpc2/handler.go:35 +0xd3 golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc000238ba0, 0xc00036eb40, 0xc0002a3810, 0xea7e80, 0xc00036e720, 0xc000378340, 0x7fe93c608650, 0xc00036e6c0) /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/jsonrpc2/handler.go:103 +0x86 created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1 /home/nakama/.gvm/pkgsets/go1.13/global/pkg/mod/golang.org/x/tools@v0.0.0-20200708181441-6004c8539734/internal/jsonrpc2/handler.go:100 +0x171 [Error - 4:38:00 PM] Connection to server got closed. Server will not be restarted. [Error - 4:38:00 PM] Request textDocument/documentSymbol failed. Error: Connection got disposed. at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25) at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at StreamMessageWriter.fireClose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27) at Socket. (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46) at Socket.emit (events.js:203:13) at Pipe. (net.js:588:12) [Error - 4:38:00 PM] Request textDocument/codeAction failed. Error: Connection got disposed. at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25) at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at StreamMessageWriter.fireClose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27) at Socket. (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46) at Socket.emit (events.js:203:13) at Pipe. (net.js:588:12) [Error - 4:38:00 PM] Request textDocument/documentLink failed. Error: Connection got disposed. at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25) at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at StreamMessageWriter.fireClose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27) at Socket. (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46) at Socket.emit (events.js:203:13) at Pipe. (net.js:588:12) [Error - 4:38:00 PM] Request textDocument/foldingRange failed. Error: Connection got disposed. at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25) at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at StreamMessageWriter.fireClose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27) at Socket. (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46) at Socket.emit (events.js:203:13) at Pipe. (net.js:588:12) [Error - 4:38:00 PM] Request textDocument/codeLens failed. Error: Connection got disposed. at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:904:25) at Object.dispose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:74:35) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2309:42) at LanguageClient.handleConnectionClosed (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/main.js:155:15) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-languageclient/lib/client.js:2296:18) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at closeHandler (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/main.js:240:26) at CallbackList.invoke (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:62:39) at Emitter.fire (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/events.js:121:36) at StreamMessageWriter.fireClose (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:39:27) at Socket. (/home/nakama/.vscode/extensions/golang.go-0.15.1/node_modules/vscode-jsonrpc/lib/messageWriter.js:58:46) at Socket.emit (events.js:203:13) at Pipe. (net.js:588:12) OPTIONAL: If you would like to share more information, you can attach your complete gopls logs. NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE. DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.
stamblerre commented 4 years ago

Thank you for the report!

/cc @heschik because I believe you looked into gitlens files at some point? Based on the crash, it looks like the entire workspace root is a gitlens file, though I don't really understand how that works.

leguminosa commented 4 years ago

yes it's true, when opening changes with previous revision, I accidentally pressed Explore Repository from Revision and everytime my repo is in that "state" (older revisions), gopls will panic.

The thing is, I don't know how to "undo" that state and return to normal state and from https://github.com/eamodio/vscode-gitlens/issues/997 the gitlens itself stated that you cannot return to normal state, thus gopls will stuck in its panic state right at the start of vscode running and renders it unusable.

It's a certainty that this gopls and gitlens have something ...

hyangah commented 4 years ago

gitlens implements a custom file system provider using vscode's FileSystemProvider API on top of git.

Not sure how much go list can handle the partial info.

There are other document schemes https://github.com/eamodio/vscode-gitlens/blob/master/src/constants.ts#L54 but I don't know how others interact with editors and potentially triggers requests to the language server.

gopherbot commented 4 years ago

Change https://golang.org/cl/244602 mentions this issue: internal/lsp: check URIs of all workspace folders

heschi commented 4 years ago

One way or another, I'm pretty sure this is fixed. Please comment if you disagree.