Skip to content

Commit

Permalink
🐛 adding timeout for RPC call (#678)
Browse files Browse the repository at this point in the history
This cuased a problem when the language server is OOM killed and the
read step was always waiting causing an indefinite hang. This will
timeout these requests.

Signed-off-by: Shawn Hurley <[email protected]>
  • Loading branch information
shawn-hurley committed Jul 29, 2024
1 parent 1efb419 commit fb8315c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"regexp"
"strings"
"sync"
"time"

"github.com/go-logr/logr"
"github.com/konveyor/analyzer-lsp/jsonrpc2"
Expand Down Expand Up @@ -137,7 +138,9 @@ func (p *javaServiceClient) GetAllSymbols(ctx context.Context, query, location s
}

var refs []protocol.WorkspaceSymbol
err := p.rpc.Call(ctx, "workspace/executeCommand", wsp, &refs)
// If it takes us 5min to complete a request, then we are in trouble
timeOutCtx, _ := context.WithTimeout(ctx, 5*time.Minute)
err := p.rpc.Call(timeOutCtx, "workspace/executeCommand", wsp, &refs)
if err != nil {
if jsonrpc2.IsRPCClosed(err) {
p.log.Error(err, "connection to the language server is closed, language server is not running")
Expand Down

0 comments on commit fb8315c

Please sign in to comment.