-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make proc-macro bidirectional calls cancellation safe #21410
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
base: master
Are you sure you want to change the base?
Make proc-macro bidirectional calls cancellation safe #21410
Conversation
ChayimFriedman2
left a comment
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.
Few comments.
| fn handle_failure(failure: Result<bidirectional::SubResponse, ProcMacroClientError>) -> ! { | ||
| match failure { | ||
| Err(ProcMacroClientError::Cancelled { reason }) => { | ||
| panic_any(ProcMacroCancelMarker { reason }); |
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.
| panic_any(ProcMacroCancelMarker { reason }); | |
| resume_unwind(ProcMacroCancelMarker { reason }); |
There is no need to incur the panic handler in this case
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.
Here we are not continuing an existing panic. If something goes wrong on the client side, we catch the panic there and convert it into a cancellation message. Up to this point, there is no panic on the server side. We then intentionally originate a new panic here with a marker, which is later caught at the thread join boundary.
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.
We do want to resume_unwind this as otherwise on every cancellation in this flow we will print the backtrace. resume_unwind is really just panicking but without invoking the panic handler. This is really more us trying to bubble up an error in this case without being noisy about it. note that I am only talking about this branch, the other two remaining panics is fine.
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.
oh!!! I understand it better now, thanks for clarification.
ChayimFriedman2
left a comment
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.
Thanks!
bbeab04 to
fa34bd7
Compare
fa34bd7 to
711aae6
Compare
711aae6 to
b2cf390
Compare
Catch panics in subrequest callbacks, reply with Cancel, and propagate cancellation to the proc-macro server