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(iroh): log inner errors #2423

Merged
merged 2 commits into from
Jun 28, 2024
Merged

refactor(iroh): log inner errors #2423

merged 2 commits into from
Jun 28, 2024

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Jun 28, 2024

Description

we currently abort the loop on outer errors (errors from spawn). But we do not look at inner errors (task returns properly but returns an error) at all.

This logs the inner errors as debug! and coninues.

Also checks if the outer error is actually a panic, and continues the loop otherwise.

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.
  • All breaking changes documented.

we currently abort the loop on outer errors (errors from spawn). But we do
not look at inner errors (task returns properly but returns an error) at
all.

This logs the inner errors as debug! and coninues.
Don't exit the main loop just because an inner task is cancelled.
Comment on lines +312 to +322
Some(Err(outer)) => {
if outer.is_panic() {
error!("Task panicked: {outer:?}");
break;
} else if outer.is_cancelled() {
debug!("Task cancelled: {outer:?}");
} else {
error!("Task failed: {outer:?}");
break;
}
}
Copy link
Contributor

@matheus23 matheus23 Jun 28, 2024

Choose a reason for hiding this comment

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

Do we need to print cancellations?
And IIUC, the third case is impossible. It's either a cancel or a panic: https://docs.rs/tokio/latest/src/tokio/runtime/task/error.rs.html#15-18

Suggested change
Some(Err(outer)) => {
if outer.is_panic() {
error!("Task panicked: {outer:?}");
break;
} else if outer.is_cancelled() {
debug!("Task cancelled: {outer:?}");
} else {
error!("Task failed: {outer:?}");
break;
}
}
Some(Err(outer)) if outer.is_panic() => {
error!("Task panicked: {outer:?}");
break;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to print cancellations? And IIUC, the third case is impossible. It's either a cancel or a panic: https://docs.rs/tokio/latest/src/tokio/runtime/task/error.rs.html#15-18

Yeah, I thought so as well, but then why don't they expose an enum? The way the JoinError API is written it seems that they want to keep the possibility open to have a third 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.

Do we need to print cancellations?

Not sure if they would ever happen at all. But if it happens, I would like to know.

Copy link
Contributor

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

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

I have a minor nit, but I'd say this fixes something important and would also be fine as-is 👍

@matheus23
Copy link
Contributor

What do you think of renaming this PR fix(iroh)? IMO it is a fix.

@rklaehn
Copy link
Contributor Author

rklaehn commented Jun 28, 2024

What do you think of renaming this PR fix(iroh)? IMO it is a fix.

Not sure. It does not change the behaviour of the program except for logging, so calling it a fix seems wrong.

@rklaehn rklaehn added this pull request to the merge queue Jun 28, 2024
Merged via the queue into main with commit da3f84b Jun 28, 2024
26 checks passed
@rklaehn rklaehn deleted the log-inner-error branch July 1, 2024 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants