#!stacks
"sigpanic" && "modindex.(*Index).Lookup" && "cache.(*goplsSource).resolveCacheReferences"

Issue created by stacks.

func (s *goplsSource) resolveCacheReferences(missing imports.References) ([]*result, error) {
    ix, err := s.S.view.ModcacheIndex()
    if err != nil {
        event.Error(s.ctx, "resolveCacheReferences", err)  <----------- missing return
    }

    found := make(map[string]*result)
    for pkg, nms := range missing {
        var ks []string
        for k := range nms {
            ks = append(ks, k)
        }
        cs := ix.LookupAll(pkg, ks...) // map[importPath][]Candidate        <-------- panics within here

This stack sKaGhw was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/arm64 other,vscode (1)

Dups: nSR9Wg x4Uhuw oAH9Ug 6exHug SO76sQ b_Sm8g MWR90Q MigjvA gwPnLQ iArnDA 3N7w2Q 69MJkg -S39nQ

Comment From: adonovan

The fix may be as simple as a return statement. Whatever it is, let's cherrypick it into rc3.

Comment From: adonovan

This stack nSR9Wg was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 linux/amd64 other,vscode (1)

This stack x4Uhuw was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.2 linux/amd64 vscode (5)
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 linux/amd64 other,vscode (37)

Comment From: gabyhelp

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: gopherbot

Change https://go.dev/cl/680258 mentions this issue: gopls/internal/cache: add missing error check

Comment From: adonovan

This stack oAH9Ug was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/arm64 other,vscode (20)

Comment From: adonovan

This stack 6exHug was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.2 windows/amd64 other,vscode (37)

This stack SO76sQ was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.2 windows/amd64 other,vscode (10)

Comment From: adonovan

This stack b_Sm8g was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.3 go1.24.4 darwin/arm64 other,vscode (11)

This stack MWR90Q was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.3 go1.24.4 darwin/arm64 other,vscode (36)

Comment From: adonovan

This stack MigjvA was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.3 go1.24.4 windows/amd64 vscode (2)

This stack gwPnLQ was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.3 go1.24.4 windows/amd64 vscode (8)

Comment From: nikolaydubina

go pls crashes every 5min now in VSCode for me...

Comment From: adonovan

Thanks for the report. I see a second problem in the source: modindex.ReadIndex may return (nil, nil), which it documents, but some of its callers are oblivious to this edge case and assume that err==nil => ix != nil. This leads to crashes.

I'll prepare a fix and a patch release today.

@pjweinb

Comment From: nikolaydubina

@adonovan this issue may be duplicate. FYI

  • https://github.com/golang/go/issues/74280
  • https://github.com/golang/vscode-go/issues/3786

Comment From: adonovan

I plan to roll back the config setting to the previous implementation, since the fix is not entirely trivial and I don't want to make things worse.

Comment From: gopherbot

Change https://go.dev/cl/682715 mentions this issue: gopls/internal/settings: revert to old goimports index

Comment From: gopherbot

Change https://go.dev/cl/682755 mentions this issue: [gopls-release-branch.0.19] gopls/internal/settings: revert to old goimports index

Comment From: adonovan

This stack iArnDA was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.3 go1.25rc1 darwin/arm64 vscode-insiders (1)

Comment From: gopherbot

Change https://go.dev/cl/682717 mentions this issue: internal/modindex: various fixes

Comment From: adonovan

This stack 3N7w2Q was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0-pre.3 go1.24.4 linux/amd64 vscode (25)
golang.org/x/tools/gopls@v0.19.0 go1.24.4 darwin/amd64 vscode (1)
golang.org/x/tools/gopls@v0.19.0 go1.24.2 darwin/amd64 vscode (3)
golang.org/x/tools/gopls@v0.19.0 go1.24.4 linux/amd64 vscode (28)

This stack 69MJkg was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0 go1.24.4 darwin/amd64 vscode (6)
golang.org/x/tools/gopls@v0.19.0-pre.3 go1.24.4 darwin/amd64 other,vscode (15)
golang.org/x/tools/gopls@v0.19.0 go1.24.2 darwin/amd64 vscode (10)
golang.org/x/tools/gopls@v0.19.0 go1.24.4 linux/amd64 vscode (57)
golang.org/x/tools/gopls@v0.19.0-pre.3 go1.24.4 linux/amd64 vscode (94)

Comment From: adonovan

This stack -S39nQ was reported by telemetry:

golang.org/x/tools/gopls@v0.19.0 go1.25rc1 darwin/arm64 other,vscode,vscode-insiders (11)