fix(zalouser): cap probe timeout timer · openclaw/openclaw@a6a99b9
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime"; |
1 | 2 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { probeZalouser } from "./probe.js"; |
3 | 4 | import { getZaloUserInfo } from "./zalo-js.js"; |
@@ -57,4 +58,14 @@ describe("probeZalouser", () => {
|
57 | 58 | error: "Not authenticated", |
58 | 59 | }); |
59 | 60 | }); |
| 61 | + |
| 62 | +it("caps oversized lookup timeout before scheduling", async () => { |
| 63 | +vi.useFakeTimers(); |
| 64 | +mockGetUserInfo.mockReturnValueOnce(new Promise(() => undefined)); |
| 65 | +const timeoutSpy = vi.spyOn(globalThis, "setTimeout"); |
| 66 | + |
| 67 | +void probeZalouser("default", Number.MAX_SAFE_INTEGER); |
| 68 | + |
| 69 | +expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS); |
| 70 | +}); |
60 | 71 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import type { BaseProbeResult } from "openclaw/plugin-sdk/channel-contract"; |
2 | 2 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
| 3 | +import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime"; |
3 | 4 | import type { ZcaUserInfo } from "./types.js"; |
4 | 5 | import { getZaloUserInfo } from "./zalo-js.js"; |
5 | 6 | |
@@ -16,7 +17,7 @@ export async function probeZalouser(
|
16 | 17 | ? await Promise.race([ |
17 | 18 | getZaloUserInfo(profile), |
18 | 19 | new Promise<null>((resolve) => |
19 | | -setTimeout(() => resolve(null), Math.max(timeoutMs, 1000)), |
| 20 | +setTimeout(() => resolve(null), resolveTimerTimeoutMs(timeoutMs, 1000, 1000)), |
20 | 21 | ), |
21 | 22 | ]) |
22 | 23 | : await getZaloUserInfo(profile); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。