1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:54:43 -07:00

internal/lsp: prevent initial workspace load from being canceled

In one of the many iterations on CL 212102, the contexts propagated
through the initial workspace load were allowed to be canceled. This
should not be allowed because the initial workspace load has to be
completed.

Change-Id: I6c6273b4e58fb9041af518f329f4766ed5f1f81b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/213641
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2020-01-07 14:41:40 -05:00
parent 428f1ab0ca
commit e8a26f4160
2 changed files with 7 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import (
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/telemetry/log"
"golang.org/x/tools/internal/xcontext"
errors "golang.org/x/xerrors"
)
@ -165,11 +166,13 @@ func (s *Server) addFolders(ctx context.Context, folders []protocol.WorkspaceFol
for _, folder := range folders {
uri := span.NewURI(folder.URI)
_, snapshot, err := s.addView(ctx, folder.Name, span.NewURI(folder.URI))
view, snapshot, err := s.addView(ctx, folder.Name, span.NewURI(folder.URI))
if err != nil {
viewErrors[uri] = err
continue
}
// Make sure that this does not get canceled.
ctx := xcontext.Detach(view.BackgroundContext())
go s.diagnoseSnapshot(ctx, snapshot)
}
if len(viewErrors) > 0 {

View File

@ -10,6 +10,7 @@ import (
"golang.org/x/tools/internal/lsp/protocol"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/xcontext"
errors "golang.org/x/xerrors"
)
@ -52,6 +53,8 @@ func (s *Server) updateConfiguration(ctx context.Context, changed interface{}) e
if err != nil {
return err
}
// Make sure that this does not get canceled.
ctx := xcontext.Detach(view.BackgroundContext())
go s.diagnoseSnapshot(ctx, view.Snapshot())
}
return nil