New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: canceled requests with Timeout set always return a Timeout error #16094

Closed
FiloSottile opened this Issue Jun 17, 2016 · 10 comments

Comments

Projects
None yet
8 participants
@FiloSottile
Member

FiloSottile commented Jun 17, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

go version devel +9e8fa1e Fri Jun 17 15:18:39 2016 +0000 darwin/amd64

  1. What did you do?

Make a http.Client with a Timeout. Cancel the request.

https://play.golang.org/p/v-QbAxdj-3

  1. What did you expect to see?

If the cause was not a Client.Timeout, then the error should be left alone.

net/http: request canceled
  1. What did you see instead?

The error is

net/http: request canceled (Client.Timeout exceeded while reading body)

This is because reqWasCanceled returns true whatever the reason for the cancelation is, be it a library user cancel or a Timeout. Then cancelTimerBody.Read uses that function to add the message.

The (Client.Timeout exceeded while awaiting headers) message is more likely to be correct (even if slightly racy), because it only adds the message if !deadline.IsZero() && !time.Now().Before(deadline).

@ianlancetaylor ianlancetaylor changed the title from Canceled requests with timeout always mention Client.Timeout in the error to net/http: canceled requests with timeout always mention Client.Timeout in the error Jun 17, 2016

@ianlancetaylor ianlancetaylor added this to the Go1.8 milestone Jun 17, 2016

@FiloSottile

This comment has been minimized.

Show comment
Hide comment
@FiloSottile

FiloSottile Jun 17, 2016

Member

Looking into it, this is not only the error message. The error is actually a net Timeout.

Member

FiloSottile commented Jun 17, 2016

Looking into it, this is not only the error message. The error is actually a net Timeout.

@FiloSottile FiloSottile changed the title from net/http: canceled requests with timeout always mention Client.Timeout in the error to net/http: canceled requests with Timeout set always return a Timeout error Jun 17, 2016

@gopherbot

This comment has been minimized.

Show comment
Hide comment
@gopherbot

gopherbot commented Jun 17, 2016

CL https://golang.org/cl/24230 mentions this issue.

@bradfitz

This comment has been minimized.

Show comment
Hide comment
@bradfitz

bradfitz Jun 29, 2016

Member

@FiloSottile, is this a regression from Go 1.6?

Member

bradfitz commented Jun 29, 2016

@FiloSottile, is this a regression from Go 1.6?

@FiloSottile

This comment has been minimized.

Show comment
Hide comment
@FiloSottile

FiloSottile Jun 29, 2016

Member
Member

FiloSottile commented Jun 29, 2016

@odeke-em

This comment has been minimized.

Show comment
Hide comment
Member

odeke-em commented Nov 1, 2016

@gopherbot

This comment has been minimized.

Show comment
Hide comment
@gopherbot

gopherbot commented Nov 1, 2016

CL https://golang.org/cl/32478 mentions this issue.

@bradfitz bradfitz self-assigned this Nov 10, 2016

@gopherbot gopherbot closed this in 7448eb4 Nov 10, 2016

@KingRider

This comment has been minimized.

Show comment
Hide comment
@KingRider

KingRider Jan 26, 2017

return stopTimer, timedOut.isSet
is wrong!

Check L303
https://go-review.googlesource.com/#/c/32478/1/src/net/http/client.go@303

Please is what correct? But a continue problem

net/http: TLS handshake timeout

KingRider commented Jan 26, 2017

return stopTimer, timedOut.isSet
is wrong!

Check L303
https://go-review.googlesource.com/#/c/32478/1/src/net/http/client.go@303

Please is what correct? But a continue problem

net/http: TLS handshake timeout

@bradfitz

This comment has been minimized.

Show comment
Hide comment
@bradfitz

bradfitz Jan 26, 2017

Member

@KingRider, we don't track comments on closed issues. Please file a new bug if you have a reproducible problem with the Go master branch.

Member

bradfitz commented Jan 26, 2017

@KingRider, we don't track comments on closed issues. Please file a new bug if you have a reproducible problem with the Go master branch.

@keitaj

This comment has been minimized.

Show comment
Hide comment
@keitaj

keitaj Mar 6, 2017

Where is cancelTimerBody.Read used?

keitaj commented Mar 6, 2017

Where is cancelTimerBody.Read used?

@bradfitz

This comment has been minimized.

Show comment
Hide comment
@bradfitz

bradfitz Mar 6, 2017

Member

@keitaj, we don't track comments on closed issues. Please file a new bug if you have a reproducible problem with the Go master branch.

Member

bradfitz commented Mar 6, 2017

@keitaj, we don't track comments on closed issues. Please file a new bug if you have a reproducible problem with the Go master branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.