From 9759300d72c5195efe9d91044b9e2270609af8bc Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 6 Nov 2019 17:03:37 -0500 Subject: [PATCH] Revert change suggested by vet. See the comment for details. (#7815) --- api/client.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/client.go b/api/client.go index 66bb729785e8..38cfbd6d62bc 100644 --- a/api/client.go +++ b/api/client.go @@ -790,10 +790,15 @@ START: return nil, LastOutputStringError } - var cancel context.CancelFunc if timeout != 0 { - ctx, cancel = context.WithTimeout(ctx, timeout) - defer cancel() + // NOTE: this leaks a timer. But when we defer a cancel call here for + // the returned function we see errors in tests with contxt canceled. + // Although the request is done by the time we exit this function it is + // still causing something else to go wrong. Maybe it ends up being + // tied to the response somehow and reading the response body ends up + // checking it, or something. I don't know, but until we can chase this + // down, keep it not-canceled even though vet complains. + ctx, _ = context.WithTimeout(ctx, timeout) } req.Request = req.Request.WithContext(ctx)