Skip to content

Conversation

@Shourya742
Copy link
Contributor

Catch panics in subrequest callbacks, reply with Cancel, and propagate cancellation to the proc-macro server

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2026
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a 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 });
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
panic_any(ProcMacroCancelMarker { reason });
resume_unwind(ProcMacroCancelMarker { reason });

There is no need to incur the panic handler in this case

Copy link
Contributor Author

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.

Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

Thanks!

@Shourya742 Shourya742 force-pushed the 2026-01-06-improve-bidirectional-cancellation branch 2 times, most recently from bbeab04 to fa34bd7 Compare January 11, 2026 10:42
@Shourya742 Shourya742 force-pushed the 2026-01-06-improve-bidirectional-cancellation branch from fa34bd7 to 711aae6 Compare January 11, 2026 11:10
@Shourya742 Shourya742 force-pushed the 2026-01-06-improve-bidirectional-cancellation branch from 711aae6 to b2cf390 Compare January 11, 2026 11:11
@Shourya742 Shourya742 requested a review from Veykril January 11, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants