Make proc-macro bidirectional calls cancellation safe#21410
Make proc-macro bidirectional calls cancellation safe#21410Veykril merged 11 commits intorust-lang:masterfrom
Conversation
| 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.
| 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.
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.
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.
oh!!! I understand it better now, thanks for clarification.
711aae6 to
b2cf390
Compare
e32cc52 to
f303bd5
Compare
Catch panics in subrequest callbacks, reply with Cancel, and propagate cancellation to the proc-macro server