mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 03:02:45 +00:00
fix: reset stale execution state after SIGUSR1 in-process restart (#15195)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 676f9ec451
Co-authored-by: joeykrug <5925937+joeykrug@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -146,6 +146,23 @@ export function setHeartbeatWakeHandler(next: HeartbeatWakeHandler | null): () =
|
||||
handlerGeneration += 1;
|
||||
const generation = handlerGeneration;
|
||||
handler = next;
|
||||
if (next) {
|
||||
// New lifecycle starting (e.g. after SIGUSR1 in-process restart).
|
||||
// Clear any timer metadata from the previous lifecycle so stale retry
|
||||
// cooldowns do not delay a fresh handler.
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
timer = null;
|
||||
timerDueAt = null;
|
||||
timerKind = null;
|
||||
// Reset module-level execution state that may be stale from interrupted
|
||||
// runs in the previous lifecycle. Without this, `running === true` from
|
||||
// an interrupted heartbeat blocks all future schedule() attempts, and
|
||||
// `scheduled === true` can cause spurious immediate re-runs.
|
||||
running = false;
|
||||
scheduled = false;
|
||||
}
|
||||
if (handler && pendingWake) {
|
||||
schedule(DEFAULT_COALESCE_MS, "normal");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user