diff --git a/.golangci.yml b/.golangci.yml index 5858c0e6a5453..de4c40e0670a9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -42,6 +42,8 @@ linters-settings: - '^fmt\.Errorf(# use errors\.Errorf instead)?$' - '^logrus\.(Trace|Debug|Info|Warn|Warning|Error|Fatal)(f|ln)?(# use bklog\.G or bklog\.L instead of logrus directly)?$' - '^context\.WithCancel(# use context\.WithCancelCause instead)?$' + - '^context\.WithTimeout(# use context\.WithTimeoutCause instead)?$' + - '^context\.WithDeadline(# use context\.WithDeadline instead)?$' - '^ctx\.Err(# use context\.Cause instead)?$' importas: alias: diff --git a/cache/remotecache/azblob/exporter.go b/cache/remotecache/azblob/exporter.go index 3a971f2f504c4..580703098ddfd 100644 --- a/cache/remotecache/azblob/exporter.go +++ b/cache/remotecache/azblob/exporter.go @@ -150,8 +150,9 @@ func (ce *exporter) uploadManifest(ctx context.Context, manifestKey string, read return errors.Wrap(err, "error creating container client") } - ctx, cnclFn := context.WithTimeout(ctx, time.Minute*5) - defer cnclFn() + ctx, cnclFn := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, time.Minute*5, errors.WithStack(context.DeadlineExceeded)) + defer cnclFn(errors.WithStack(context.Canceled)) _, err = blobClient.Upload(ctx, reader, &azblob.BlockBlobUploadOptions{}) if err != nil { @@ -170,8 +171,9 @@ func (ce *exporter) uploadBlobIfNotExists(ctx context.Context, blobKey string, r return errors.Wrap(err, "error creating container client") } - uploadCtx, cnclFn := context.WithTimeout(ctx, time.Minute*5) - defer cnclFn() + uploadCtx, cnclFn := context.WithCancelCause(ctx) + uploadCtx, _ = context.WithTimeoutCause(uploadCtx, time.Minute*5, errors.WithStack(context.DeadlineExceeded)) + defer cnclFn(errors.WithStack(context.Canceled)) // Only upload if the blob doesn't exist eTagAny := azblob.ETagAny diff --git a/cache/remotecache/azblob/utils.go b/cache/remotecache/azblob/utils.go index 5fa87d24c3cbb..ff27a9e4676b1 100644 --- a/cache/remotecache/azblob/utils.go +++ b/cache/remotecache/azblob/utils.go @@ -133,8 +133,9 @@ func createContainerClient(ctx context.Context, config *Config) (*azblob.Contain } } - ctx, cnclFn := context.WithTimeout(ctx, time.Second*60) - defer cnclFn() + ctx, cnclFn := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, time.Second*60, errors.WithStack(context.DeadlineExceeded)) + defer cnclFn(errors.WithStack(context.Canceled)) containerClient, err := serviceClient.NewContainerClient(config.Container) if err != nil { @@ -148,8 +149,9 @@ func createContainerClient(ctx context.Context, config *Config) (*azblob.Contain var se *azblob.StorageError if errors.As(err, &se) && se.ErrorCode == azblob.StorageErrorCodeContainerNotFound { - ctx, cnclFn := context.WithTimeout(ctx, time.Minute*5) - defer cnclFn() + ctx, cnclFn := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, time.Minute*5, errors.WithStack(context.DeadlineExceeded)) + defer cnclFn(errors.WithStack(context.Canceled)) _, err := containerClient.Create(ctx, &azblob.ContainerCreateOptions{}) if err != nil { return nil, errors.Wrapf(err, "failed to create cache container %s", config.Container) @@ -177,8 +179,9 @@ func blobExists(ctx context.Context, containerClient *azblob.ContainerClient, bl return false, errors.Wrap(err, "error creating blob client") } - ctx, cnclFn := context.WithTimeout(ctx, time.Second*60) - defer cnclFn() + ctx, cnclFn := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, time.Second*60, errors.WithStack(context.DeadlineExceeded)) + defer cnclFn(errors.WithStack(context.Canceled)) _, err = blobClient.GetProperties(ctx, &azblob.BlobGetPropertiesOptions{}) if err == nil { return true, nil diff --git a/cache/remotecache/local/local.go b/cache/remotecache/local/local.go index 818f9b441ee4f..5acff332bff1f 100644 --- a/cache/remotecache/local/local.go +++ b/cache/remotecache/local/local.go @@ -105,8 +105,9 @@ func getContentStore(ctx context.Context, sm *session.Manager, g session.Group, if sessionID == "" { return nil, errors.New("local cache exporter/importer requires session") } - timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() + timeoutCtx, cancel := context.WithCancelCause(context.Background()) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) caller, err := sm.Get(timeoutCtx, sessionID, false) if err != nil { diff --git a/client/build_test.go b/client/build_test.go index 7b325cb05dd65..9bd77ce25bb56 100644 --- a/client/build_test.go +++ b/client/build_test.go @@ -933,7 +933,7 @@ func testClientGatewayContainerPID1Tty(t *testing.T, sb integration.Sandbox) { output := bytes.NewBuffer(nil) b := func(ctx context.Context, c client.Client) (*client.Result, error) { - ctx, timeout := context.WithTimeout(ctx, 10*time.Second) + ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil) defer timeout() st := llb.Image("busybox:latest") @@ -1015,7 +1015,7 @@ func testClientGatewayContainerCancelPID1Tty(t *testing.T, sb integration.Sandbo output := bytes.NewBuffer(nil) b := func(ctx context.Context, c client.Client) (*client.Result, error) { - ctx, cancel := context.WithTimeout(ctx, 10*time.Second) + ctx, cancel := context.WithTimeoutCause(ctx, 10*time.Second, nil) defer cancel() st := llb.Image("busybox:latest") @@ -1141,7 +1141,7 @@ func testClientGatewayContainerExecTty(t *testing.T, sb integration.Sandbox) { inputR, inputW := io.Pipe() output := bytes.NewBuffer(nil) b := func(ctx context.Context, c client.Client) (*client.Result, error) { - ctx, timeout := context.WithTimeout(ctx, 10*time.Second) + ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil) defer timeout() st := llb.Image("busybox:latest") @@ -1233,7 +1233,7 @@ func testClientGatewayContainerCancelExecTty(t *testing.T, sb integration.Sandbo inputR, inputW := io.Pipe() output := bytes.NewBuffer(nil) b := func(ctx context.Context, c client.Client) (*client.Result, error) { - ctx, timeout := context.WithTimeout(ctx, 10*time.Second) + ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil) defer timeout() st := llb.Image("busybox:latest") @@ -2132,7 +2132,7 @@ func testClientGatewayContainerSignal(t *testing.T, sb integration.Sandbox) { product := "buildkit_test" b := func(ctx context.Context, c client.Client) (*client.Result, error) { - ctx, timeout := context.WithTimeout(ctx, 10*time.Second) + ctx, timeout := context.WithTimeoutCause(ctx, 10*time.Second, nil) defer timeout() st := llb.Image("busybox:latest") diff --git a/client/client_test.go b/client/client_test.go index dafe667188880..6b5f38a7b82c3 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -9832,7 +9832,7 @@ func testLLBMountPerformance(t *testing.T, sb integration.Sandbox) { def, err := st.Marshal(sb.Context()) require.NoError(t, err) - timeoutCtx, cancel := context.WithTimeout(sb.Context(), time.Minute) + timeoutCtx, cancel := context.WithTimeoutCause(sb.Context(), time.Minute, nil) defer cancel() _, err = c.Solve(timeoutCtx, def, SolveOpt{}, nil) require.NoError(t, err) diff --git a/cmd/buildctl/common/common.go b/cmd/buildctl/common/common.go index b943ac2a9a0ff..edf10c468e5e3 100644 --- a/cmd/buildctl/common/common.go +++ b/cmd/buildctl/common/common.go @@ -91,9 +91,10 @@ func ResolveClient(c *cli.Context) (*client.Client, error) { timeout := time.Duration(c.GlobalInt("timeout")) if timeout > 0 { - ctx2, cancel := context.WithTimeout(ctx, timeout*time.Second) + ctx2, cancel := context.WithCancelCause(ctx) + ctx2, _ = context.WithTimeoutCause(ctx2, timeout*time.Second, errors.WithStack(context.DeadlineExceeded)) ctx = ctx2 - defer cancel() + defer cancel(errors.WithStack(context.Canceled)) } cl, err := client.New(ctx, c.GlobalString("addr"), opts...) diff --git a/control/gateway/gateway.go b/control/gateway/gateway.go index b680c6e8dbb34..4a59c48c2546f 100644 --- a/control/gateway/gateway.go +++ b/control/gateway/gateway.go @@ -59,8 +59,9 @@ func (gwf *GatewayForwarder) lookupForwarder(ctx context.Context) (gateway.LLBBr return nil, errors.New("no buildid found in context") } - ctx, cancel := context.WithTimeout(ctx, 3*time.Second) - defer cancel() + ctx, cancel := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, 3*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) go func() { <-ctx.Done() diff --git a/executor/containerdexecutor/executor.go b/executor/containerdexecutor/executor.go index 5089bab0ead2c..45abed99b79ba 100644 --- a/executor/containerdexecutor/executor.go +++ b/executor/containerdexecutor/executor.go @@ -371,7 +371,7 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces } }() - var cancel func() + var cancel func(error) var killCtxDone <-chan struct{} ctxDone := ctx.Done() for { @@ -379,13 +379,14 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces case <-ctxDone: ctxDone = nil var killCtx context.Context - killCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second) + killCtx, cancel = context.WithCancelCause(context.Background()) + killCtx, _ = context.WithTimeoutCause(killCtx, 10*time.Second, errors.WithStack(context.DeadlineExceeded)) killCtxDone = killCtx.Done() p.Kill(killCtx, syscall.SIGKILL) io.Cancel() case status := <-statusCh: if cancel != nil { - cancel() + cancel(errors.WithStack(context.Canceled)) } trace.SpanFromContext(ctx).AddEvent( "Container exited", @@ -411,7 +412,7 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces return nil case <-killCtxDone: if cancel != nil { - cancel() + cancel(errors.WithStack(context.Canceled)) } io.Cancel() return errors.Errorf("failed to kill process on cancel") diff --git a/executor/runcexecutor/executor.go b/executor/runcexecutor/executor.go index 702419a4db0ea..8555f75149006 100644 --- a/executor/runcexecutor/executor.go +++ b/executor/runcexecutor/executor.go @@ -532,8 +532,9 @@ func (k procKiller) Kill(ctx context.Context) (err error) { // this timeout is generally a no-op, the Kill ctx should already have a // shorter timeout but here as a fail-safe for future refactoring. - ctx, timeout := context.WithTimeout(ctx, 10*time.Second) - defer timeout() + ctx, cancel := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, 10*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) if k.pidfile == "" { // for `runc run` process we use `runc kill` to terminate the process @@ -615,17 +616,17 @@ func runcProcessHandle(ctx context.Context, killer procKiller) (*procHandle, con for { select { case <-ctx.Done(): - killCtx, timeout := context.WithTimeout(context.Background(), 7*time.Second) + killCtx, timeout := context.WithCancelCause(context.Background()) + killCtx, _ = context.WithTimeoutCause(killCtx, 7*time.Second, errors.WithStack(context.DeadlineExceeded)) if err := p.killer.Kill(killCtx); err != nil { select { case <-killCtx.Done(): - timeout() cancel(errors.WithStack(context.Cause(ctx))) return default: } } - timeout() + timeout(errors.WithStack(context.Canceled)) select { case <-time.After(50 * time.Millisecond): case <-p.ended: @@ -673,10 +674,11 @@ func (p *procHandle) WaitForReady(ctx context.Context) error { // We wait for up to 10s for the runc pid to be reported. If the started // callback is non-nil it will be called after receiving the pid. func (p *procHandle) WaitForStart(ctx context.Context, startedCh <-chan int, started func()) error { - startedCtx, timeout := context.WithTimeout(ctx, 10*time.Second) - defer timeout() + ctx, cancel := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, 10*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) select { - case <-startedCtx.Done(): + case <-ctx.Done(): return errors.New("go-runc started message never received") case runcPid, ok := <-startedCh: if !ok { diff --git a/exporter/local/export.go b/exporter/local/export.go index 47186c018ddf6..96d8352bb04fd 100644 --- a/exporter/local/export.go +++ b/exporter/local/export.go @@ -61,8 +61,9 @@ func (e *localExporter) Config() *exporter.Config { } func (e *localExporterInstance) Export(ctx context.Context, inp *exporter.Source, sessionID string) (map[string]string, exporter.DescriptorReference, error) { - timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() + timeoutCtx, cancel := context.WithCancelCause(ctx) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) if e.opts.Epoch == nil { if tm, ok, err := epoch.ParseSource(inp); err != nil { diff --git a/exporter/oci/export.go b/exporter/oci/export.go index 935806383f7e8..f1a1aa55c83b5 100644 --- a/exporter/oci/export.go +++ b/exporter/oci/export.go @@ -198,8 +198,9 @@ func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source return nil, nil, errors.Errorf("invalid variant %q", e.opt.Variant) } - timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() + timeoutCtx, cancel := context.WithCancelCause(ctx) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false) if err != nil { diff --git a/exporter/tar/export.go b/exporter/tar/export.go index 7259f6b24a9ab..c932000e594b7 100644 --- a/exporter/tar/export.go +++ b/exporter/tar/export.go @@ -143,8 +143,9 @@ func (e *localExporterInstance) Export(ctx context.Context, inp *exporter.Source fs = d.FS } - timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() + timeoutCtx, cancel := context.WithCancelCause(ctx) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false) if err != nil { diff --git a/frontend/dockerfile/dockerfile_test.go b/frontend/dockerfile/dockerfile_test.go index b9c8a4a3afdb5..fae8b37ebd181 100644 --- a/frontend/dockerfile/dockerfile_test.go +++ b/frontend/dockerfile/dockerfile_test.go @@ -2692,8 +2692,9 @@ COPY . . fstest.CreateFile(".dockerignore", []byte("!\n"), 0600), ) - ctx, cancel := context.WithTimeout(sb.Context(), 15*time.Second) - defer cancel() + ctx, cancel := context.WithCancelCause(sb.Context()) + ctx, _ = context.WithTimeoutCause(ctx, 15*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) c, err := client.New(ctx, sb.Address()) require.NoError(t, err) diff --git a/frontend/gateway/grpcclient/client.go b/frontend/gateway/grpcclient/client.go index 56322b2785e83..5013f9b42f1e1 100644 --- a/frontend/gateway/grpcclient/client.go +++ b/frontend/gateway/grpcclient/client.go @@ -43,8 +43,9 @@ type GrpcClient interface { } func New(ctx context.Context, opts map[string]string, session, product string, c pb.LLBBridgeClient, w []client.WorkerInfo) (GrpcClient, error) { - pingCtx, pingCancel := context.WithTimeout(ctx, 15*time.Second) - defer pingCancel() + pingCtx, pingCancel := context.WithCancelCause(ctx) + pingCtx, _ = context.WithTimeoutCause(pingCtx, 15*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer pingCancel(errors.WithStack(context.Canceled)) resp, err := c.Ping(pingCtx, &pb.PingRequest{}) if err != nil { return nil, err diff --git a/session/group.go b/session/group.go index 4b9ba221f5fea..e701d1d292060 100644 --- a/session/group.go +++ b/session/group.go @@ -72,8 +72,9 @@ func (sm *Manager) Any(ctx context.Context, g Group, f func(context.Context, str return errors.Errorf("no active sessions") } - timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() + timeoutCtx, cancel := context.WithCancelCause(ctx) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) c, err := sm.Get(timeoutCtx, id, false) if err != nil { lastErr = err diff --git a/session/grpc.go b/session/grpc.go index b16e927aa856b..c7b1ef40df5e1 100644 --- a/session/grpc.go +++ b/session/grpc.go @@ -104,9 +104,11 @@ func monitorHealth(ctx context.Context, cc *grpc.ClientConn, cancelConn func(err healthcheckStart := time.Now() timeout := time.Duration(math.Max(float64(defaultHealthcheckDuration), float64(lastHealthcheckDuration)*1.5)) - ctx, cancel := context.WithTimeout(ctx, timeout) + + ctx, cancel := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, timeout, errors.WithStack(context.DeadlineExceeded)) _, err := healthClient.Check(ctx, &grpc_health_v1.HealthCheckRequest{}) - cancel() + cancel(errors.WithStack(context.Canceled)) lastHealthcheckDuration = time.Since(healthcheckStart) logFields := logrus.Fields{ diff --git a/solver/jobs.go b/solver/jobs.go index b0678cae2a905..5ddafa614f4a7 100644 --- a/solver/jobs.go +++ b/solver/jobs.go @@ -488,8 +488,9 @@ func (jl *Solver) NewJob(id string) (*Job, error) { } func (jl *Solver) Get(id string) (*Job, error) { - ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second) - defer cancel() + ctx, cancel := context.WithCancelCause(context.Background()) + ctx, _ = context.WithTimeoutCause(ctx, 6*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) go func() { <-ctx.Done() diff --git a/solver/llbsolver/solver.go b/solver/llbsolver/solver.go index b912006738079..e1e9152bddeb3 100644 --- a/solver/llbsolver/solver.go +++ b/solver/llbsolver/solver.go @@ -195,8 +195,9 @@ func (s *Solver) recordBuildHistory(ctx context.Context, id string, req frontend } } - ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) - defer cancel() + ctx, cancel := context.WithCancelCause(context.Background()) + ctx, _ = context.WithTimeoutCause(ctx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) var mu sync.Mutex ch := make(chan *client.SolveStatus) diff --git a/source/containerimage/ocilayout.go b/source/containerimage/ocilayout.go index 2358b5339b7aa..2cc75f6defd00 100644 --- a/source/containerimage/ocilayout.go +++ b/source/containerimage/ocilayout.go @@ -123,8 +123,9 @@ func (r *ociLayoutResolver) info(ctx context.Context, ref reference.Spec) (conte func (r *ociLayoutResolver) withCaller(ctx context.Context, f func(context.Context, session.Caller) error) error { if r.store.SessionID != "" { - timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() + timeoutCtx, cancel := context.WithCancelCause(ctx) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) caller, err := r.sm.Get(timeoutCtx, r.store.SessionID, false) if err != nil { diff --git a/source/local/source.go b/source/local/source.go index 31f3dd7e26d39..7afcbb1c562ba 100644 --- a/source/local/source.go +++ b/source/local/source.go @@ -141,8 +141,9 @@ func (ls *localSourceHandler) Snapshot(ctx context.Context, g session.Group) (ca return ls.snapshotWithAnySession(ctx, g) } - timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second) - defer cancel() + timeoutCtx, cancel := context.WithCancelCause(ctx) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) caller, err := ls.sm.Get(timeoutCtx, sessionID, false) if err != nil { diff --git a/util/testutil/integration/registry.go b/util/testutil/integration/registry.go index b2111db0dcef4..198069b659929 100644 --- a/util/testutil/integration/registry.go +++ b/util/testutil/integration/registry.go @@ -67,8 +67,9 @@ http: } deferF.Append(stop) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() + ctx, cancel := context.WithCancelCause(context.Background()) + ctx, _ = context.WithTimeoutCause(ctx, 5*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer cancel(errors.WithStack(context.Canceled)) url, err = detectPort(ctx, rc) if err != nil { return "", nil, err diff --git a/util/tracing/otlptracegrpc/client.go b/util/tracing/otlptracegrpc/client.go index 3c05f43940473..5d54b14129445 100644 --- a/util/tracing/otlptracegrpc/client.go +++ b/util/tracing/otlptracegrpc/client.go @@ -71,8 +71,9 @@ func (c *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc ctx, cancel := c.connection.ContextWithStop(ctx) defer cancel(errors.WithStack(context.Canceled)) - ctx, tCancel := context.WithTimeout(ctx, 30*time.Second) - defer tCancel() + ctx, tCancel := context.WithCancelCause(ctx) + ctx, _ = context.WithTimeoutCause(ctx, 30*time.Second, errors.WithStack(context.DeadlineExceeded)) + defer tCancel(errors.WithStack(context.Canceled)) ctx = c.connection.ContextWithMetadata(ctx) err := func() error { diff --git a/worker/tests/common.go b/worker/tests/common.go index 0a6d8be4c84f2..54c3d8afc39aa 100644 --- a/worker/tests/common.go +++ b/worker/tests/common.go @@ -49,7 +49,7 @@ func TestWorkerExec(t *testing.T, w *base.Worker) { id := identity.NewID() // verify pid1 exits when stdin sees EOF - ctxTimeout, cancelTimeout := context.WithTimeout(ctx, 5*time.Second) + ctxTimeout, cancelTimeout := context.WithTimeoutCause(ctx, 5*time.Second, nil) started := make(chan struct{}) pipeR, pipeW := io.Pipe() go func() {