-
Notifications
You must be signed in to change notification settings - Fork 271
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(app/core): prepare rescue body for http-body upgrade #3616
Open
cratelyn
wants to merge
1
commit into
main
Choose a base branch
from
kate/app-core.rescue-body-is-prepared-for-poll-frame
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
refactor(app/core): prepare rescue body for http-body upgrade #3616
cratelyn
wants to merge
1
commit into
main
from
kate/app-core.rescue-body-is-prepared-for-poll-frame
+61
−37
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Base automatically changed from
kate/app-core.rescue-body-continues-to-yield-ready-none
to
main
February 13, 2025 15:41
424fa9a
to
ba9231d
Compare
this commit makes some minor alterations to our error recovery body middleware. see linkerd/linkerd2#8733 for more information. this commit removes an `assert!` statement from the implementation of `<Response<R, B> as Body>::poll_data()`. see the documentation of `Body::poll_frame()`: > Once the end of the stream is reached, implementations should > continue to return [`Poll::Ready(None)`]. hyperium/http-body@1090bff#diff-33aabe8c2aaa7614022addf244245e09bbff576a67a9ae3c6938c8a868201d36R60-R61 to do this, this commit introduces a distinct terminal state `Inner::Rescued` to represent when the underlying `B`-typed body has yielded an error and been rescued. once in this state the body will yield no more data frames, instead yielding a collection of trailers describing the mid-stream error that was encountered by the underlying body. the call to `R::rescue` is also moved down into the helper function fka `grpc_trailers()`. this helps the function follow the grain of our "state machine" a little more directly. see #3615, #3614, and #3611 for pretext to this change. Signed-off-by: katelyn martin <[email protected]>
ba9231d
to
4bcb5fe
Compare
cratelyn
commented
Feb 14, 2025
Comment on lines
-78
to
+87
} => { | ||
// should not be calling poll_data if we have set trailers derived from an error | ||
assert!(trailers.is_none()); | ||
match inner.poll_data(cx) { | ||
Poll::Ready(Some(Err(error))) => { | ||
let SyntheticHttpResponse { | ||
grpc_status, | ||
message, | ||
.. | ||
} = rescue.rescue(error)?; | ||
let t = Self::grpc_trailers(grpc_status, &message, *emit_headers); | ||
*trailers = Some(t); | ||
Poll::Ready(None) | ||
} | ||
data => data, | ||
} => match inner.poll_data(cx) { | ||
Poll::Ready(Some(Err(error))) => { | ||
// The inner body has yielded an error, which we will try to rescue. If so, | ||
// store our synthetic trailers reporting the error. | ||
let trailers = Self::rescue(error, rescue, *emit_headers)?; | ||
self.set_rescued(trailers); | ||
Poll::Ready(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the important part to look at ☝️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refactor(app/core): prepare rescue body for http-body upgrade
this commit makes some minor alterations to our error recovery body
middleware. see linkerd/linkerd2#8733 for more
information.
this commit removes an
assert!
statement from the implementation of<Response<R, B> as Body>::poll_data()
. see the documentation ofBody::poll_frame()
:hyperium/http-body@1090bff#diff-33aabe8c2aaa7614022addf244245e09bbff576a67a9ae3c6938c8a868201d36R60-R61
to do this, this commit introduces a distinct terminal state
Inner::Rescued
to represent when the underlyingB
-typed body hasyielded an error and been rescued. once in this state the body will
yield no more data frames, instead yielding a collection of trailers
describing the mid-stream error that was encountered by the underlying
body.
the call to
R::rescue
is also moved down into the helper function fkagrpc_trailers()
. this helps the function follow the grain of our"state machine" a little more directly.
see #3615, #3614, and #3611 for pretext to this change.