@@ -3,6 +3,7 @@ import http, { type ClientRequest, type IncomingMessage } from "node:http";
|
3 | 3 | import https from "node:https"; |
4 | 4 | import { generateSecureUuid } from "openclaw/plugin-sdk/core"; |
5 | 5 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
| 6 | +import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime"; |
6 | 7 | |
7 | 8 | export type SignalRpcOptions = { |
8 | 9 | baseUrl: string; |
@@ -106,7 +107,7 @@ function normalizeSignalSseTimeoutMs(timeoutMs: number): number | null {
|
106 | 107 | if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) { |
107 | 108 | return null; |
108 | 109 | } |
109 | | -return timeoutMs; |
| 110 | +return resolveTimerTimeoutMs(timeoutMs, DEFAULT_TIMEOUT_MS); |
110 | 111 | } |
111 | 112 | |
112 | 113 | function requestSignalHttpText( |
@@ -120,13 +121,14 @@ function requestSignalHttpText(
|
120 | 121 | }, |
121 | 122 | ): Promise<SignalHttpResponse> { |
122 | 123 | assertSignalHttpProtocol(url, "HTTP"); |
| 124 | +const timeoutMs = resolveTimerTimeoutMs(options.timeoutMs, DEFAULT_TIMEOUT_MS); |
123 | 125 | const client = url.protocol === "https:" ? https : http; |
124 | 126 | return new Promise((resolve, reject) => { |
125 | 127 | let settled = false; |
126 | 128 | let request: ClientRequest | undefined; |
127 | 129 | const deadline = setTimeout(() => { |
128 | | -request?.destroy(new Error(`Signal HTTP exceeded deadline after ${options.timeoutMs}ms`)); |
129 | | -}, options.timeoutMs); |
| 130 | +request?.destroy(new Error(`Signal HTTP exceeded deadline after ${timeoutMs}ms`)); |
| 131 | +}, timeoutMs); |
130 | 132 | deadline.unref?.(); |
131 | 133 | const cleanup = () => { |
132 | 134 | clearTimeout(deadline); |
@@ -180,8 +182,8 @@ function requestSignalHttpText(
|
180 | 182 | }); |
181 | 183 | }, |
182 | 184 | ); |
183 | | -request.setTimeout(options.timeoutMs, () => { |
184 | | -request?.destroy(new Error(`Signal HTTP timed out after ${options.timeoutMs}ms`)); |
| 185 | +request.setTimeout(timeoutMs, () => { |
| 186 | +request?.destroy(new Error(`Signal HTTP timed out after ${timeoutMs}ms`)); |
185 | 187 | }); |
186 | 188 | request.on("error", rejectOnce); |
187 | 189 | if (options.body !== undefined) { |
|