fix(gateway): cancel delayed maintenance on shutdown · openclaw/openclaw@1e19034
vincentkoc
·
2026-05-06
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -86,6 +86,7 @@ Docs: https://docs.openclaw.ai
|
86 | 86 | |
87 | 87 | ### Fixes |
88 | 88 | |
| 89 | +- Gateway/shutdown: cancel delayed post-ready maintenance during close and suppress maintenance/cron startup after quick restarts, preventing orphaned background timers. Thanks @vincentkoc. |
89 | 90 | - Agents/generated media: treat attachment-style message tool actions as completed chat sends, preventing duplicate fallback media posts when generated files were already uploaded. |
90 | 91 | - Control UI/sessions: show each session's agent runtime in the Sessions table and allow filtering by runtime labels, matching the Agents panel runtime wording. Thanks @vincentkoc. |
91 | 92 | - Discord/streaming: show live reasoning text in progress drafts instead of a bare `Reasoning` status line. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -56,9 +56,24 @@ describe("gateway startup import boundaries", () => {
|
56 | 56 | const closeStart = serverImpl.indexOf("close: async (opts)"); |
57 | 57 | const hookStart = serverImpl.indexOf("runGlobalGatewayStopSafely", closeStart); |
58 | 58 | const markStart = serverImpl.indexOf("markClosePreludeStarted();", closeStart); |
| 59 | +const markHelperStart = serverImpl.indexOf("const markClosePreludeStarted = () => {"); |
| 60 | +const markHelperEnd = serverImpl.indexOf("};", markHelperStart); |
| 61 | +const postReadyStart = serverImpl.indexOf("scheduleGatewayPostReadyMaintenance({"); |
| 62 | +const postReadyEnd = serverImpl.indexOf("});", postReadyStart); |
| 63 | +const postReadyBlock = serverImpl.slice(postReadyStart, postReadyEnd); |
59 | 64 | |
60 | 65 | expect(closeStart).toBeGreaterThan(-1); |
61 | 66 | expect(markStart).toBeGreaterThan(closeStart); |
62 | 67 | expect(markStart).toBeLessThan(hookStart); |
| 68 | +expect(markHelperStart).toBeGreaterThan(-1); |
| 69 | +expect(serverImpl.slice(markHelperStart, markHelperEnd)).toContain( |
| 70 | +"clearPostReadyMaintenanceTimer();", |
| 71 | +); |
| 72 | +expect(postReadyStart).toBeGreaterThan(-1); |
| 73 | +expect(postReadyBlock).toContain("isClosing: () => closePreludeStarted"); |
| 74 | +expect(postReadyBlock).toContain("if (closePreludeStarted)"); |
| 75 | +expect(postReadyBlock).toContain( |
| 76 | +"shouldStartCron: () => !closePreludeStarted && !gatewayCronStartHandled", |
| 77 | +); |
63 | 78 | }); |
64 | 79 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1524,14 +1524,28 @@ export async function startGatewayServer(
|
1524 | 1524 | onStarted: () => { |
1525 | 1525 | postReadyMaintenanceTimer = null; |
1526 | 1526 | }, |
1527 | | -startMaintenance: earlyRuntime.startMaintenance, |
| 1527 | +startMaintenance: async () => { |
| 1528 | +if (closePreludeStarted) { |
| 1529 | +return null; |
| 1530 | +} |
| 1531 | +return earlyRuntime.startMaintenance(); |
| 1532 | +}, |
1528 | 1533 | applyMaintenance: (maintenance) => { |
| 1534 | +if (closePreludeStarted) { |
| 1535 | +clearInterval(maintenance.tickInterval); |
| 1536 | +clearInterval(maintenance.healthInterval); |
| 1537 | +clearInterval(maintenance.dedupeCleanup); |
| 1538 | +if (maintenance.mediaCleanup) { |
| 1539 | +clearInterval(maintenance.mediaCleanup); |
| 1540 | +} |
| 1541 | +return; |
| 1542 | +} |
1529 | 1543 | runtimeState.tickInterval = maintenance.tickInterval; |
1530 | 1544 | runtimeState.healthInterval = maintenance.healthInterval; |
1531 | 1545 | runtimeState.dedupeCleanup = maintenance.dedupeCleanup; |
1532 | 1546 | runtimeState.mediaCleanup = maintenance.mediaCleanup; |
1533 | 1547 | }, |
1534 | | -shouldStartCron: () => !gatewayCronStartHandled, |
| 1548 | +shouldStartCron: () => !closePreludeStarted && !gatewayCronStartHandled, |
1535 | 1549 | markCronStartHandled: () => { |
1536 | 1550 | gatewayCronStartHandled = true; |
1537 | 1551 | }, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。