We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Please answer these questions before submitting your issue. Thanks!
go version
$ go version go version go1.7.3 darwin/amd64
go env
$ go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/abg/dev/go" GORACE="" GOROOT="/usr/local/Cellar/go/1.7.3/libexec" GOTOOLDIR="/usr/local/Cellar/go/1.7.3/libexec/pkg/tool/darwin_amd64" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8z/qdzjsr3n5l72vdg67zr6xkjc0000gn/T/go-build965147697=/tmp/go-build -gno-record-gcc-switches -fno-common" CXX="clang++" CGO_ENABLED="1"
If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best.
package main import ( "context" "fmt" "log" "net/http" "time" ) func main() { req, err := http.NewRequest("GET", "https://httpbin.org/delay/3", nil) if err != nil { log.Fatal(err) } ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond) defer cancel() _, err = http.DefaultClient.Do(req.WithContext(ctx)) fmt.Printf("err = %v (%T)\n", err, err) fmt.Printf("ctx.Err() = %v (%T)\n", ctx.Err(), ctx.Err()) }
err = context deadline exceeded (context.deadlineExceededError) ctx.Err() = context deadline exceeded (context.deadlineExceededError)
err should be a "context deadline exceeded" error and it should be the same as ctx.Error().
err
ctx.Error()
err and ctx.Error() are different. err is a "request canceled" error even though the context's cancel() hasn't been called yet.
cancel()
err = Get https://httpbin.org/delay/3: net/http: request canceled while waiting for connection (*url.Error) ctx.Err() = context deadline exceeded (context.deadlineExceededError)
Related to #16381, which was addressed in ctxhttp using,
ctxhttp
if err != nil { select { case <-ctx.Done(): err = ctx.Err() default: } }
The text was updated successfully, but these errors were encountered:
Workaround for golang/go#17711
05f0fed
@odeke-em, was there a CL for this?
Sorry, something went wrong.
Yap, there is https://go-review.googlesource.com/#/c/24230 but it's been stalled. Also seems like this issue is a duplicate of #16094.
No branches or pull requests
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
err
should be a "context deadline exceeded" error and it should be the same asctx.Error()
.What did you see instead?
err
andctx.Error()
are different.err
is a "request canceled" error even though the context'scancel()
hasn't been called yet.Related to #16381, which was addressed in
ctxhttp
using,The text was updated successfully, but these errors were encountered: