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

swarm.DialError should wrap DialError.DialErrors #2436

Closed
Tracked by #2481
sukunrt opened this issue Jul 19, 2023 · 0 comments · Fixed by #2437
Closed
Tracked by #2481

swarm.DialError should wrap DialError.DialErrors #2436

sukunrt opened this issue Jul 19, 2023 · 0 comments · Fixed by #2437
Labels
kind/enhancement A net-new feature or improvement to an existing feature

Comments

@sukunrt
Copy link
Member

sukunrt commented Jul 19, 2023

Almost all of the users of swarm.DialError either expect swarm.DialError to wrap over errors of individual dials. To summarise this should return true

errors.Is(
		&DialError{
			Peer:       "pid",
			DialErrors: []TransportError{
			{ 
              Address: ma.StringCast("/ip4/1.2.3.4/tcp/1234"), 
			  Cause: ErrDialBackoff}
			},
		},
		ErrDialBackoff,
	)

I think this is a reasonable thing to fix. Some previous discussion here: #2414 (comment)

There are a lot of usecases here:
https://github.com/search?q=swarm.DialError&type=code

A few examples:

https://github.com/ipni/cassette/blob/ca08e5af7376dc249cbb3a1173bbc6b37e38ceea/metrics.go#L301-L309

		case *swarm.DialError:
			errKind = "dial-error"
			for _, de := range e.DialErrors {
				if de.Cause.Error() == "dial backoff" {
					errKind = "dial-backoff"
					break
				}
			}

https://github.com/libp2p/go-libp2p-kad-dht/blob/ee95d1ab03c47aab03218e18d07483f51e7787e4/fullrt/dht.go#L315

dialErr, ok := err.(*swarm.DialError)
				if ok {
					for _, transportErr := range dialErr.DialErrors {
						if errors.Is(transportErr.Cause, network.ErrResourceLimitExceeded) {
							limitErrOnce.Do(func() { logger.Errorf(rtRefreshLimitsMsg) })
						}
					}
				}

https://github.com/smartcontractkit/libocr/blob/82b910bef5c1c95cc7a886091ccfc1895bde76f5/networking/ocr_endpoint_v1.go#L428

		if !errors.Is(err, swarm.ErrDialBackoff) {
@sukunrt sukunrt added the kind/enhancement A net-new feature or improvement to an existing feature label Jul 19, 2023
@marten-seemann marten-seemann mentioned this issue Jul 19, 2023
21 tasks
@marten-seemann marten-seemann mentioned this issue Aug 15, 2023
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant