fix(clawhub): clamp request timeouts · openclaw/openclaw@8cd0c11
vincentkoc
·
2026-06-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
|
3 | 3 | import fs from "node:fs/promises"; |
4 | 4 | import os from "node:os"; |
5 | 5 | import path from "node:path"; |
| 6 | +import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion"; |
6 | 7 | import { afterEach, describe, expect, it, vi } from "vitest"; |
7 | 8 | import { withTempDir } from "../test-helpers/temp-dir.js"; |
8 | 9 | import { captureEnv, setTestEnvValue } from "../test-utils/env.js"; |
@@ -570,6 +571,27 @@ describe("clawhub helpers", () => {
|
570 | 571 | expect(url.searchParams.has("version")).toBe(false); |
571 | 572 | }); |
572 | 573 | |
| 574 | +it("clamps oversized ClawHub request timeouts before scheduling", async () => { |
| 575 | +const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout"); |
| 576 | +try { |
| 577 | +await expect( |
| 578 | +fetchClawHubSkillCard({ |
| 579 | +slug: "agentreceipt", |
| 580 | +timeoutMs: Number.MAX_SAFE_INTEGER, |
| 581 | +fetchImpl: async () => |
| 582 | +new Response("# Agent Receipt\n", { |
| 583 | +status: 200, |
| 584 | +headers: { "content-type": "text/markdown; charset=utf-8" }, |
| 585 | +}), |
| 586 | +}), |
| 587 | +).resolves.toBe("# Agent Receipt\n"); |
| 588 | + |
| 589 | +expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
| 590 | +} finally { |
| 591 | +setTimeoutSpy.mockRestore(); |
| 592 | +} |
| 593 | +}); |
| 594 | + |
573 | 595 | it("fetches generated Skill Card markdown from an exact verified card URL", async () => { |
574 | 596 | let requestedUrl = ""; |
575 | 597 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。