Skip to content

Commit

Permalink
Update comment in client about canceling the WithTimeout context
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed May 8, 2020
1 parent 59b14ac commit 81afb3f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 81afb3f

Please sign in to comment.