fix(process): clamp queue task timeouts · openclaw/openclaw@1f6ae32
vincentkoc
·
2026-06-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Command queue tests cover bounded command execution and queue ordering. |
| 2 | +import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion"; |
2 | 3 | import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures"; |
3 | 4 | import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
4 | 5 | import { CommandLane } from "./lanes.js"; |
@@ -504,6 +505,34 @@ describe("command queue", () => {
|
504 | 505 | } |
505 | 506 | }); |
506 | 507 | |
| 508 | +it("clamps oversized task timeouts before arming lane timers", async () => { |
| 509 | +const lane = `timeout-clamp-lane-${Date.now()}-${Math.random().toString(16).slice(2)}`; |
| 510 | +setCommandLaneConcurrency(lane, 1); |
| 511 | + |
| 512 | +vi.useFakeTimers(); |
| 513 | +try { |
| 514 | +const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout"); |
| 515 | +const blocker = createDeferred(); |
| 516 | +const task = enqueueCommandInLane( |
| 517 | +lane, |
| 518 | +async () => { |
| 519 | +await blocker.promise; |
| 520 | +}, |
| 521 | +{ taskTimeoutMs: MAX_TIMER_TIMEOUT_MS + 1 }, |
| 522 | +); |
| 523 | + |
| 524 | +await Promise.resolve(); |
| 525 | + |
| 526 | +expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
| 527 | + |
| 528 | +blocker.resolve(); |
| 529 | +await task; |
| 530 | +setTimeoutSpy.mockRestore(); |
| 531 | +} finally { |
| 532 | +vi.useRealTimers(); |
| 533 | +} |
| 534 | +}); |
| 535 | + |
507 | 536 | it("task timeout renews from progress timestamps", async () => { |
508 | 537 | const lane = `timeout-progress-lane-${Date.now()}-${Math.random().toString(16).slice(2)}`; |
509 | 538 | setCommandLaneConcurrency(lane, 1); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。