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: expose context Canceled/DeadlineExceeded error #36208

Open
pascaldekloe opened this issue Dec 18, 2019 · 5 comments
Open

net: expose context Canceled/DeadlineExceeded error #36208

pascaldekloe opened this issue Dec 18, 2019 · 5 comments

Comments

@pascaldekloe
Copy link
Contributor

@pascaldekloe pascaldekloe commented Dec 18, 2019

Issue #28529 could be solved with the new error wrapping now.

What did you do?

Check for context.Canceled with errors.Is seems reasonable.

https://play.golang.org/p/-JTEZXGyfQ6

$ go version
go version go1.13.5 darwin/amd64
@dmitshur
Copy link
Member

@dmitshur dmitshur commented Dec 20, 2019

Thanks for making this issue.

Can you elaborate on what problem it would help solve to expose this information? What is it that cannot be done (or can be done, but inconveniently) before this is resolved, and how will it be done after?

/cc @mikioh @bradfitz @ianlancetaylor

Also /cc @bcmills who commented on the relevant issue #28529.

@pascaldekloe
Copy link
Contributor Author

@pascaldekloe pascaldekloe commented Dec 21, 2019

Generally speaking you want to continue the abort (by returning context.Canceled) if the context expired. Dial errors on the other hand must be reported [logged]. Maybe a retry or two?

@bcmills
Copy link
Member

@bcmills bcmills commented Feb 19, 2020

@pascaldekloe, that doesn't really answer @dmitshur's questions.

@pascaldekloe
Copy link
Contributor Author

@pascaldekloe pascaldekloe commented Feb 19, 2020

Yes it does @bcmills. You always block my issues with the WaitingForInfo label for some reason. Not helping at all.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 19, 2020

I believe the point here is to permit using error.Is(err, context.Canceled) on the error returned by net.Dial to see if the Dial failed because the context was canceled. That doesn't work today because of the mapErr function in net/net.go (https://golang.org/src/net/net.go?#L413) which changes context.Canceled to the net package internal error errCanceled. This was done when DialContext was introduced so that the net package operations would continue returning the errors that they always returned. That is because when DialContext was introduced, the existing DialTimeout function was changed to use a context. Changing the error from the internal errCanceled to context.Canceled would certainly break some tests and possible break some real code as well.

So this issue is basically: drop mapErr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.