You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using go-amqp. I dial (which calls net's Dialer.DialContext) in a goroutine and then a situation happens in the main routine which causes me to cancel while dialing.
// Main routinectx, cancel:=context.WithCancel(context.Background())
gootherRoutine(ctx)
defercancel()
Which of converts the error into a string without wrapping it properly. mapErr(ctxErr) converts the error to an instance of canceledError, which is defined with the following comment.
// canceledError lets us return the same error string we have always// returned, while still being Is context.Canceled.typecanceledErrorstruct{}
Which means that canceledError is even meant to be Is compatible with context.Canceled, which is immediately thrown away by calling .Error().
Proposed solution
DNSError should additionally store the original error and implement Unwrap so that Is can properly work to detect the error that spawned the DNSError.
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am using
go-amqp
. I dial (which callsnet
'sDialer.DialContext
) in a goroutine and then a situation happens in the main routine which causes me to cancel while dialing.What did you expect to see?
true
What did you see instead?
false
Why this is happening
In
lookupIPAddr
innet/lookup.go
we see the following code.Which of converts the error into a string without wrapping it properly.
mapErr(ctxErr)
converts the error to an instance ofcanceledError
, which is defined with the following comment.Which means that
canceledError
is even meant to beIs
compatible withcontext.Canceled
, which is immediately thrown away by calling.Error()
.Proposed solution
DNSError
should additionally store the original error and implementUnwrap
so thatIs
can properly work to detect the error that spawned theDNSError
.The text was updated successfully, but these errors were encountered: