runtime: report adapter task panics
This commit is contained in:
parent
23234b96ca
commit
1173e3af38
|
|
@ -620,7 +620,12 @@ where
|
||||||
{
|
{
|
||||||
let (tx, rx) = mpsc::sync_channel(1);
|
let (tx, rx) = mpsc::sync_channel(1);
|
||||||
self.spawn_on_adapter_runtime(async move {
|
self.spawn_on_adapter_runtime(async move {
|
||||||
let _ = tx.send(task.await);
|
let handle = tokio::spawn(task);
|
||||||
|
let result = match handle.await {
|
||||||
|
Ok(result) => result,
|
||||||
|
Err(err) => Err(format!("worker adapter task failed: {err}")),
|
||||||
|
};
|
||||||
|
let _ = tx.send(result);
|
||||||
})?;
|
})?;
|
||||||
Self::wait_for_runtime_task(rx)
|
Self::wait_for_runtime_task(rx)
|
||||||
}
|
}
|
||||||
|
|
@ -1412,6 +1417,22 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn adapter_runtime_reports_task_panic() {
|
||||||
|
let backend = WorkerRuntimeExecutionBackend::new(FailingFactory).unwrap();
|
||||||
|
|
||||||
|
let error = backend
|
||||||
|
.run_on_adapter_runtime(async {
|
||||||
|
panic!("adapter boom");
|
||||||
|
#[allow(unreachable_code)]
|
||||||
|
Ok::<(), String>(())
|
||||||
|
})
|
||||||
|
.unwrap_err();
|
||||||
|
|
||||||
|
assert!(error.contains("worker adapter task failed"));
|
||||||
|
assert!(error.contains("adapter boom") || error.contains("panicked"));
|
||||||
|
}
|
||||||
|
|
||||||
fn create_clean_repo() -> tempfile::TempDir {
|
fn create_clean_repo() -> tempfile::TempDir {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
git(dir.path(), &["init"]);
|
git(dir.path(), &["init"]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user