From 444a5bff7aeff057420f539b499f17e42c63eb17 Mon Sep 17 00:00:00 2001 From: gmega Date: Wed, 4 Feb 2026 16:41:22 -0300 Subject: [PATCH] fix: propagate callback cancellation so timer does not get stuck during stop --- codex/stores/maintenance.nim | 3 ++- codex/utils/timer.nim | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/codex/stores/maintenance.nim b/codex/stores/maintenance.nim index 38486239..b2fece4d 100644 --- a/codex/stores/maintenance.nim +++ b/codex/stores/maintenance.nim @@ -100,12 +100,13 @@ proc runBlockCheck( trace "Cycle completed" proc start*(self: BlockMaintainer) = - proc onTimer(): Future[void] {.async: (raises: []).} = + proc onTimer(): Future[void] {.async: (raises: [CancelledError]).} = try: await self.runBlockCheck() except CancelledError as err: trace "Running block check in block maintenance timer callback cancelled: ", err = err.msg + raise err self.timer.start(onTimer, self.interval) diff --git a/codex/utils/timer.nim b/codex/utils/timer.nim index fc22dfd3..f12b1228 100644 --- a/codex/utils/timer.nim +++ b/codex/utils/timer.nim @@ -17,7 +17,7 @@ import pkg/chronos import ../logutils type - TimerCallback* = proc(): Future[void] {.async: (raises: []).} + TimerCallback* = proc(): Future[void] {.async: (raises: [CancelledError]).} Timer* = ref object of RootObj callback: TimerCallback interval: Duration