From 51aca40cbae205870fb3851062c26af11153d724 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Thu, 25 Jan 2024 12:57:48 +0000 Subject: [PATCH] solver: use errors.Is when checking context.Cause() Since the change to replace uses of context.WithCancel with WithCancelCause, we've also begun wrapping all cancellations using errors.WithStack. This means that these would not directly match context.Canceled, so we need to make sure to use errors.Is. Signed-off-by: Justin Chadwell --- solver/errdefs/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solver/errdefs/context.go b/solver/errdefs/context.go index 68779c444674..5e0cbce1adb4 100644 --- a/solver/errdefs/context.go +++ b/solver/errdefs/context.go @@ -14,7 +14,7 @@ func IsCanceled(ctx context.Context, err error) bool { return true } // grpc does not set cancel correctly when stream gets cancelled and then Recv is called - if err != nil && context.Cause(ctx) == context.Canceled { + if err != nil && errors.Is(context.Cause(ctx), context.Canceled) { // when this error comes from containerd it is not typed at all, just concatenated string if strings.Contains(err.Error(), "EOF") { return true