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

feat(swarm): make stream uprade errors more ergonomic #3882

Merged
merged 41 commits into from
May 8, 2023

Conversation

thomaseizinger
Copy link
Contributor

@thomaseizinger thomaseizinger commented May 5, 2023

Description

The currently provided ConnectionHandlerUpgrErr is very hard to use. Not only does it have a long name, it also features 3 levels of nesting which results in a lot of boilerplate. Last but not least, it exposes multistream-select as a dependency to all protocols.

We fix all of the above by renaming the type to StreamUpgradeError and flattening out its interface. Unrecoverable errors during protocol selection are hidden within the Io variant.

Related: #3759.

Notes & open questions

Draft because it depends on #3605.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@thomaseizinger thomaseizinger added this to the v0.52.0 milestone May 5, 2023
swarm/CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me. Just one comment.

Comment on lines +472 to +473
/// No protocol could be agreed upon.
NegotiationFailed,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a side-note, we had multiple users complain, that it is hard to debug why the negotiation failed. What would have helped them is NegotiationFailed to contain the protocols the local and the remote peer offered.

That said, using DEBUG logging and looking for the multistream-select lines also helps the debugging, though a bit harder to discover.

Not to be addressed in this pull request.

Copy link
Contributor Author

@thomaseizinger thomaseizinger May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including this information will be a breaking change but we can introduce the facilities for it in a non-breaking manner once we have completely encapsulated multistream-select, meaning this is a step in the right direction in my opinion.

swarm/CHANGELOG.md Outdated Show resolved Hide resolved
Base automatically changed from feat/no-report-inbound-error to master May 8, 2023 04:54
@mergify

This comment was marked as resolved.

@thomaseizinger thomaseizinger marked this pull request as ready for review May 8, 2023 08:34
@mergify mergify bot merged commit 81c424e into master May 8, 2023
@mergify mergify bot deleted the 3759-encapsulate-multistream-select branch May 8, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants