Skip to content

x/tools/gopls: workspace loading notifications can get stuck #71967

@osiewicz

Description

@osiewicz

Go version

go version go1.23.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/hiro/Library/Caches/go-build'
GOENV='/Users/hiro/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/hiro/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/hiro/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/hiro/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/hiro/Projects/language_repositories/golang/juju/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/nl/9fwvt1l153v1sb0fsd0sn4840000gn/T/go-build3044280324=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Recently Zed stopped sending out any workspaceFolders in it's Initialize request, instead opting to fill them out when a project root is discovered. We still fill out rootUri.

What did you see happen?

Our Preview users noticed that there's now a stale notification for "Setting up workspace: Loading packages...". I dug a bit into gopls sources and it looks like it fills out workspace folders with rootUri when there are no workspace folders in initialize request: https://github.com/golang/tools/blob/5dc980c6debffbe1b319cf554f28eaf100b9fc94/gopls/internal/server/general.go#L98

I think the problem here might be that later on we send out a didChangeWorkspaceFolders notification with that same folder, which might lead to the progress token not being cancelled.

When rootUri is not present in initialization params the issue goes away.

What did you expect to see?

I expected second workspace scan to not be started if there's already (implictily registered) workspace folder of the same path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/metadataIssues related to metadata loading in gopls

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions