net/http: context deadline can cause surprising errors #64449
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Unfortunate
Milestone
Go version
go1.21.4
What operating system and processor architecture are you using (
go env
)?What did you do?
Used a context with a timeout when using
http.Client.Do
What did you expect to see?
I would expect any error returned from
Do
that was caused by the deadline elapsing be identifiable usingerrors.Is(err, context.DeadlineExceed)
.What did you see instead?
There are certain places where dialing can fail due to the deadline that return an underlying error of type
internal/poll.DeadlineExceededError
. Unlikenet.errTimeout
, this types does not implement theIs(error) bool
method to consider itself equivalent tocontext.DeadlineExceeded
.So callers must check against both
context.DeadlineExceeded
andos.ErrDeadlineExceeded
in order to determine if the returned error was due to the context deadline.The text was updated successfully, but these errors were encountered: