fix: gracefully shut down engine (#23159)

This commit is contained in:
Arsenii Kulikov
2026-03-22 23:52:53 +04:00
committed by GitHub
parent 2d2778fa24
commit c9e9db184e
2 changed files with 2 additions and 31 deletions

View File

@@ -372,7 +372,7 @@ impl EngineNodeLauncher {
);
}
}
_ = &mut on_graceful_shutdown => {
_guard = &mut on_graceful_shutdown => {
// Shutdown signal received.
// Send Terminate so the engine OS thread can exit cleanly before we
// drop the orchestrator.
@@ -390,7 +390,7 @@ impl EngineNodeLauncher {
let _ = exit.send(res);
};
ctx.task_executor()
.spawn_critical_with_shutdown_signal("consensus engine", consensus_engine);
.spawn_critical_with_graceful_shutdown_signal("consensus engine", consensus_engine);
let engine_events_for_ethstats = engine_events.new_listener();

View File

@@ -573,35 +573,6 @@ impl Runtime {
self.spawn_critical_as(name, fut, TaskKind::Blocking)
}
/// This spawns a critical task onto the runtime.
///
/// If this task panics, the [`TaskManager`] is notified.
pub fn spawn_critical_with_shutdown_signal<F>(
&self,
name: &'static str,
f: impl FnOnce(Shutdown) -> F,
) -> JoinHandle<()>
where
F: Future<Output = ()> + Send + 'static,
{
let panicked_tasks_tx = self.0.task_events_tx.clone();
let on_shutdown = self.0.on_shutdown.clone();
let fut = f(on_shutdown);
// wrap the task in catch unwind
let task = std::panic::AssertUnwindSafe(fut)
.catch_unwind()
.map_err(move |error| {
let task_error = PanickedTaskError::new(name, error);
error!("{task_error}");
let _ = panicked_tasks_tx.send(TaskEvent::Panic(task_error));
})
.map(drop)
.in_current_span();
self.0.handle.spawn(task)
}
/// This spawns a critical task onto the runtime.
///
/// If this task panics, the [`TaskManager`] is notified.