From 81afb3fdd06b981b6d886e1efadf337b293ae199 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 8 May 2020 14:48:26 -0400 Subject: [PATCH] Update comment in client about canceling the WithTimeout context --- api/client.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/api/client.go b/api/client.go index ee08f0dd57f6..93d68db18293 100644 --- a/api/client.go +++ b/api/client.go @@ -813,13 +813,10 @@ START: } if timeout != 0 { - // 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. + // Note: we purposefully do not call cancel manually. The reason is + // when canceled, the request.Body will EOF when reading due to the way + // it streams data in. Cancel will still be run when the timeout is + // hit, so this doesn't really harm anything. ctx, _ = context.WithTimeout(ctx, timeout) } req.Request = req.Request.WithContext(ctx)