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

Refactor errors (fixes #530) #556

Merged
merged 2 commits into from
Sep 28, 2021
Merged

Refactor errors (fixes #530) #556

merged 2 commits into from
Sep 28, 2021

Conversation

nox
Copy link
Contributor

@nox nox commented Aug 30, 2021

h2::Error now knows whether protocol errors happened because the user
sent them, because it was received from the remote peer, or because
the library itself emitted an error because it detected a protocol
violation.

It also keeps track of whether it came from a RST_STREAM or GO_AWAY
frame, and in the case of the latter, it includes the additional
debug data if any.

@nox nox force-pushed the errors branch 4 times, most recently from 48eb28f to c755975 Compare August 31, 2021 13:07
src/error.rs Outdated Show resolved Hide resolved
@nox nox force-pushed the errors branch 7 times, most recently from fcdcd3b to f8ccae8 Compare September 8, 2021 08:37
@nox
Copy link
Contributor Author

nox commented Sep 8, 2021

Seems like there are no tests for resets, will check that out.

@nox nox force-pushed the errors branch 15 times, most recently from d058cb7 to 276b1e2 Compare September 9, 2021 12:38
@nox nox changed the title Start refactoring errors to fix #530 Refactor errors (fixes #530) Sep 9, 2021
@nox nox changed the title Refactor errors (fixes #530) Refactor errors (fixes #530) Sep 9, 2021
@nox nox marked this pull request as ready for review September 9, 2021 12:39
Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

Nice work! I think this is a big improvement to help identify where an error actually came from. Some notes inline, some important, some just rambling at a cloud.

src/codec/framed_read.rs Show resolved Hide resolved
src/error.rs Outdated Show resolved Hide resolved
src/error.rs Outdated
Kind::GoAway(ref debug_data, reason, initiator) => {
write!(fmt, "go away from {}: {}", initiator, reason)?;
if !debug_data.is_empty() {
write!(fmt, " ({:?})", debug_data)?;
Copy link
Member

Choose a reason for hiding this comment

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

Should we be including the debug data in the Display implementation? It might be useful, or it could be complete junk. Maybe we should, but also maybe it should only be showed in Debug...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use Display and it's a bit bothersome to use Debug for one specific error.

What about Display but only the alternate format?

Copy link
Member

Choose a reason for hiding this comment

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

Hm. Alternate output might be a good use here... Do you know what other HTTP/2 libraries do with the debug-data? Like netty, or grpc, or other...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Netty doesn't format the related exception at all.

grpc-java seems to log debug data directly though.

IMO we should just always include it in Display otherwise most people won't benefit from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seanmonstar Let's merge it? 🥺

src/lib.rs Show resolved Hide resolved
src/proto/connection.rs Show resolved Hide resolved
src/proto/go_away.rs Outdated Show resolved Hide resolved
src/proto/streams/prioritize.rs Show resolved Hide resolved
src/error.rs Outdated Show resolved Hide resolved
@nox nox force-pushed the errors branch 2 times, most recently from 09909f5 to 77969a6 Compare September 13, 2021 08:14
@nox
Copy link
Contributor Author

nox commented Sep 13, 2021

The errors are fixed by #557.

h2::Error now knows whether protocol errors happened because the user
sent them, because it was received from the remote peer, or because
the library itself emitted an error because it detected a protocol
violation.

It also keeps track of whether it came from a RST_STREAM or GO_AWAY
frame, and in the case of the latter, it includes the additional
debug data if any.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants