Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,12 +741,17 @@ func registerLanguageServiceDocumentRequestHandler[Req lsproto.HasTextDocumentUR
if req.Params != nil {
params = req.Params.(Req)
}
ls, err := s.session.GetLanguageService(ctx, params.TextDocumentURI())
if err != nil {
return nil, err
}
// GetLanguageService is moved into the async closure to avoid blocking the
// dispatch loop. Previously, acquiring the language service synchronously could
// block on snapshotUpdateMu if another operation (e.g. DidOpenFile, idle cache
// clean, or a concurrent snapshot update) was holding the lock, causing the
// dispatch loop to stall and preventing responses from being sent. See #2857.
return func() error {
defer s.recover(req)
ls, err := s.session.GetLanguageService(ctx, params.TextDocumentURI())
if err != nil {
return err
}
resp, lsErr := fn(s, ctx, ls, params)
if lsErr != nil {
return lsErr
Expand Down