@@ -10,7 +10,10 @@ import fs from "node:fs/promises";
|
10 | 10 | import nodePath from "node:path"; |
11 | 11 | import { resolveFetch } from "openclaw/plugin-sdk/fetch-runtime"; |
12 | 12 | import { detectMime, parseMediaContentLength } from "openclaw/plugin-sdk/media-runtime"; |
13 | | -import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime"; |
| 13 | +import { |
| 14 | +parseStrictNonNegativeInteger, |
| 15 | +resolveTimerTimeoutMs, |
| 16 | +} from "openclaw/plugin-sdk/number-runtime"; |
14 | 17 | import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime"; |
15 | 18 | import WebSocket from "ws"; |
16 | 19 | |
@@ -77,8 +80,9 @@ async function fetchWithTimeout(url: string, init: RequestInit, timeoutMs: numbe
|
77 | 80 | if (!fetchImpl) { |
78 | 81 | throw new Error("fetch is not available"); |
79 | 82 | } |
| 83 | +const safeTimeoutMs = resolveTimerTimeoutMs(timeoutMs, DEFAULT_TIMEOUT_MS); |
80 | 84 | const controller = new AbortController(); |
81 | | -const timer = setTimeout(() => controller.abort(), timeoutMs); |
| 85 | +const timer = setTimeout(() => controller.abort(), safeTimeoutMs); |
82 | 86 | try { |
83 | 87 | return await fetchImpl(url, { ...init, signal: controller.signal }); |
84 | 88 | } finally { |
@@ -142,12 +146,13 @@ function containerReceiveCheck(
|
142 | 146 | ): Promise<{ ok: boolean; status?: number | null; error?: string | null }> { |
143 | 147 | const wsUrl = `${normalizedBaseUrl.replace(/^http/, "ws")}/v1/receive/${encodeURIComponent(account)}`; |
144 | 148 | return new Promise((resolve) => { |
| 149 | +const safeTimeoutMs = resolveTimerTimeoutMs(timeoutMs, DEFAULT_TIMEOUT_MS); |
145 | 150 | let settled = false; |
146 | 151 | let ws: WebSocket | undefined; |
147 | 152 | const timer = setTimeout(() => { |
148 | 153 | settle({ ok: false, status: null, error: "Signal container receive WebSocket timed out" }); |
149 | 154 | ws?.terminate(); |
150 | | -}, timeoutMs); |
| 155 | +}, safeTimeoutMs); |
151 | 156 | timer.unref?.(); |
152 | 157 | const settle = (result: { ok: boolean; status?: number | null; error?: string | null }) => { |
153 | 158 | if (settled) { |
|