@@ -28,6 +28,7 @@ import {
|
28 | 28 | type ProviderOperationRetryStage, |
29 | 29 | type TransientProviderRetryConfig, |
30 | 30 | } from "../provider-runtime/operation-retry.js"; |
| 31 | +import { resolveTimerTimeoutMs } from "../shared/number-coercion.js"; |
31 | 32 | import { fetchWithTimeout } from "../utils/fetch-timeout.js"; |
32 | 33 | export { fetchWithTimeout }; |
33 | 34 | export { normalizeBaseUrl } from "../agents/provider-request-config.js"; |
@@ -101,7 +102,7 @@ export function createProviderOperationDeadline(params: {
|
101 | 102 | ) { |
102 | 103 | return { label: params.label }; |
103 | 104 | } |
104 | | -const timeoutMs = Math.floor(params.timeoutMs); |
| 105 | +const timeoutMs = resolveTimerTimeoutMs(params.timeoutMs, 1); |
105 | 106 | return { |
106 | 107 | deadlineAtMs: Date.now() + timeoutMs, |
107 | 108 | label: params.label, |
@@ -113,15 +114,16 @@ export function resolveProviderOperationTimeoutMs(params: {
|
113 | 114 | deadline: ProviderOperationDeadline; |
114 | 115 | defaultTimeoutMs: number; |
115 | 116 | }): number { |
| 117 | +const defaultTimeoutMs = resolveTimerTimeoutMs(params.defaultTimeoutMs, 1); |
116 | 118 | const deadlineAtMs = params.deadline.deadlineAtMs; |
117 | 119 | if (typeof deadlineAtMs !== "number") { |
118 | | -return params.defaultTimeoutMs; |
| 120 | +return defaultTimeoutMs; |
119 | 121 | } |
120 | 122 | const remainingMs = deadlineAtMs - Date.now(); |
121 | 123 | if (remainingMs <= 0) { |
122 | 124 | throw new Error(`${params.deadline.label} timed out after ${params.deadline.timeoutMs}ms`); |
123 | 125 | } |
124 | | -return Math.max(1, Math.min(params.defaultTimeoutMs, remainingMs)); |
| 126 | +return Math.max(1, Math.min(defaultTimeoutMs, remainingMs)); |
125 | 127 | } |
126 | 128 | |
127 | 129 | export function createProviderOperationTimeoutResolver(params: { |
|