Skip to content
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: context deadline can cause surprising errors #64449

Open
jhump opened this issue Nov 29, 2023 · 2 comments
Open

net/http: context deadline can cause surprising errors #64449

jhump opened this issue Nov 29, 2023 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Unfortunate
Milestone

Comments

@jhump
Copy link

jhump commented Nov 29, 2023

Go version

go1.21.4

What operating system and processor architecture are you using (go env)?

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/jhumphries/Library/Caches/go-build'
GOENV='/Users/jhumphries/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/jhumphries/go/pkg/mod'
GONOPROXY='buf.build/gen/go,github.com/bufbuild/buf-lang'
GONOSUMDB='buf.build/gen/go,github.com/bufbuild/buf-lang'
GOOS='darwin'
GOPATH='/Users/jhumphries/go'
GOPRIVATE='buf.build/gen/go,github.com/bufbuild/buf-lang'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.21.4/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.21.4/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/jhumphries/src/connect-go/internal/conformance/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/vy/ws2js8yx4n581x_g8m_cs9jw0000gn/T/go-build1785425850=/tmp/go-build -gno-record-gcc-switches -fno-common'

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 using errors.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. Unlike net.errTimeout, this types does not implement the Is(error) bool method to consider itself equivalent to context.DeadlineExceeded.

So callers must check against both context.DeadlineExceeded and os.ErrDeadlineExceeded in order to determine if the returned error was due to the context deadline.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 29, 2023
@dmitshur dmitshur added this to the Backlog milestone Nov 29, 2023
@dmitshur
Copy link
Contributor

CC @neild.

@gopherbot
Copy link

Change https://go.dev/cl/546275 mentions this issue: internal/poll: DeadlineExceededError s/b compatible with context.DeadlineExceeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Unfortunate
Projects
None yet
Development

No branches or pull requests

4 participants