Skip to content

Commit

Permalink
Fix cancelling task leading to an error (#4195)
Browse files Browse the repository at this point in the history
  • Loading branch information
DelSkayn committed Jun 18, 2024
1 parent 26de607 commit befb185
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions lib/src/api/engine/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ pub struct Tasks {
impl Tasks {
#[cfg(not(target_arch = "wasm32"))]
pub async fn resolve(self) -> Result<(), RootError> {
self.nd.await.map_err(|e| {
error!("Node agent task failed: {}", e);
let inner_err = crate::err::Error::NodeAgent("node task failed and has been logged");
RootError::Db(inner_err)
})?;
self.lq.await.map_err(|e| {
error!("Live query task failed: {}", e);
let inner_err =
crate::err::Error::NodeAgent("live query task failed and has been logged");
RootError::Db(inner_err)
})?;
match self.nd.await {
// cancelling this task is fine, and can happen when surrealdb exits.
Ok(_) => {}
Err(e) if e.is_cancelled() => {}
Err(e) => {
error!("Node agent task failed: {}", e);
let inner_err =
crate::err::Error::NodeAgent("node task failed and has been logged");
return Err(RootError::Db(inner_err));
}
}
match self.lq.await {
Ok(_) => {}
Err(e) if e.is_cancelled() => {}
Err(e) => {
error!("Live query task failed: {}", e);
let inner_err =
crate::err::Error::NodeAgent("live query task failed and has been logged");
return Err(RootError::Db(inner_err));
}
};
Ok(())
}
}
Expand Down

0 comments on commit befb185

Please sign in to comment.