Skip to content

Commit ee1c7c4

Browse files
authored
worker: Improve job failure error logging (#8121)
`anyhow` by default only returns the top-most error when formatted via `Display`. The alternate formatting (`:#`) instructs it to return the full error chain instead. Unfortunately `tracing` does not support alternate formatting yet, so we have to call `format!()` manually.
1 parent 814bed4 commit ee1c7c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates_io_worker/src/worker.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ impl<Context: Clone + Send + Sync + 'static> Worker<Context> {
3939
sleep(self.poll_interval).await;
4040
}
4141
Err(error) => {
42-
error!(%error, "Failed to run job");
42+
let error = format!("{error:#}");
43+
error!(error, "Failed to run job");
4344
sleep(self.poll_interval).await;
4445
}
4546
}
@@ -94,7 +95,8 @@ impl<Context: Clone + Send + Sync + 'static> Worker<Context> {
9495
storage::delete_successful_job(conn, job_id)?
9596
}
9697
Err(error) => {
97-
warn!(%error, "Failed to run job");
98+
let error = format!("{error:#}");
99+
warn!(error, "Failed to run job");
98100
storage::update_failed_job(conn, job_id);
99101
}
100102
}

0 commit comments

Comments
 (0)