diff --git a/src/runtime2/connector.rs b/src/runtime2/connector.rs index 38250412efb892714887391c708e79c51977df4c..53ed270193deb762acee1587609efe37beb04349 100644 --- a/src/runtime2/connector.rs +++ b/src/runtime2/connector.rs @@ -69,7 +69,6 @@ pub(crate) enum ConnectorScheduling { Later, // Schedule for running, at some later point in time NotNow, // Do not reschedule for running Exit, // Connector has exited - Error(EvalError), // Connector has experienced a fatal error } pub(crate) struct ConnectorPDL { @@ -267,7 +266,16 @@ impl ConnectorPDL { let run_result = Self::run_prompt(&mut branch.code_state, &sched_ctx.runtime.protocol_description, &mut run_context); if let Err(eval_error) = run_result { - return ConnectorScheduling::Error(eval_error); + self.eval_error = Some(eval_error); + self.mode = Mode::SyncError; + if let Some(conclusion) = self.consensus.notify_of_fatal_branch(branch_id, comp_ctx) { + // We can exit immediately + return self.enter_non_sync_mode(conclusion, comp_ctx); + } else { + // Current branch failed. But we may have other things that are + // running. + return ConnectorScheduling::Immediate; + } } let run_result = run_result.unwrap(); @@ -408,7 +416,8 @@ impl ConnectorPDL { }; let run_result = Self::run_prompt(&mut branch.code_state, &sched_ctx.runtime.protocol_description, &mut run_context); if let Err(eval_error) = run_result { - return ConnectorScheduling::Error(eval_error); + comp_ctx.push_error(eval_error); + return ConnectorScheduling::Exit } let run_result = run_result.unwrap(); @@ -473,14 +482,7 @@ impl ConnectorPDL { // Depending on local state decide what to do let final_branch_id = match conclusion { RoundConclusion::Success(branch_id) => Some(branch_id), - RoundConclusion::Failure => if self.mode == Mode::SyncError { - // We experienced an error, so exit now - None - } else { - // We didn't experience an error, so retry - // TODO: Decide what to do with sync errors - Some(BranchId::new_invalid()) - } + RoundConclusion::Failure => None, }; if let Some(solution_branch_id) = final_branch_id { @@ -499,6 +501,9 @@ impl ConnectorPDL { // No final branch, because we're supposed to exit! self.last_finished_handled = None; self.mode = Mode::Error; + if let Some(eval_error) = self.eval_error.take() { + ctx.push_error(eval_error); + } return ConnectorScheduling::Exit; } }