Skip to content

Commit

Permalink
Merge pull request cli#4635 from cli/ssh-waiter-timeout
Browse files Browse the repository at this point in the history
Adds a timeout context to the ssh waiter to prevent indefinite hanging
  • Loading branch information
reybard authored Nov 2, 2021
2 parents 175da0f + 97d85d0 commit 3a4d947
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/liveshare/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"time"

"github.com/opentracing/opentracing-go"
"github.com/sourcegraph/jsonrpc2"
Expand Down Expand Up @@ -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.Minute)
defer cancel()

return waiter.Wait(waitCtx, result)
}

type nullHandler struct{}
Expand Down

0 comments on commit 3a4d947

Please sign in to comment.