Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

net: make errCanceled and errTimeout be "errors.Is" context.Canceled and context.DeadlineExceeded #51428

Copy link
Copy link
@gprossliner

Description

@gprossliner
Issue body actions

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

$ go version
go version go1.17.6 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/guenter.prossliner@world-direct.at/.cache/go-build"
GOENV="/home/guenter.prossliner@world-direct.at/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/guenter.prossliner@world-direct.at/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/guenter.prossliner@world-direct.at/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/guenter.prossliner@world-direct.at/proj/polly2/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build117018826=/tmp/go-build -gno-record-gcc-switches"

What did you do?

This is part of a bigger application, but here is a repo:
https://go.dev/play/p/mD-R6gerA4c

What did you expect to see?

I expect that the net.OpErr which is returned by net.dialer.DialContext included the wrapped original error, which is a context.Canceled error.

This may be the problematic function. There is also a TODO from @bradfitz

go/src/net/net.go

Lines 419 to 434 in 40e24a9

// mapErr maps from the context errors to the historical internal net
// error values.
//
// TODO(bradfitz): get rid of this after adjusting tests and making
// context.DeadlineExceeded implement net.Error?
func mapErr(err error) error {
switch err {
case context.Canceled:
return errCanceled
case context.DeadlineExceeded:
return errTimeout
default:
return err
}
}

What did you see instead?

UNEXPECTED:dial tcp: operation was canceled
EXPECTED: Get "http://github.com": context canceled
bcmills and ainar-ghopehook, gprossliner, moredure and twmb

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.