Adds a timeout context to the ssh waiter to prevent indefinite hanging

This commit is contained in:
Jeff Hubbard 2021-10-27 15:40:49 -07:00
parent d794a929da
commit c18e54189c

View file

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"time"
"github.com/opentracing/opentracing-go"
"github.com/sourcegraph/jsonrpc2"
@ -32,7 +33,11 @@ func (r *rpcClient) do(ctx context.Context, method string, args, result interfac
return fmt.Errorf("error dispatching %q call: %w", method, err)
}
return waiter.Wait(ctx, result)
// timeout for waiter in case a connection cannot be made
waitCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()
return waiter.Wait(waitCtx, result)
}
type nullHandler struct{}