Skip to content

Commit 927fc8e

Browse files
committed
fix: enforce max timeout and improve error message consistency
- Clamp timeout to max 600000ms (10 minutes) as documented - External routes now report timeout value in error message
1 parent 8104f29 commit 927fc8e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

apps/sim/lib/core/security/input-validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ export async function secureFetchWithPinnedIP(
10111011

10121012
req.on('timeout', () => {
10131013
req.destroy()
1014-
reject(new Error('Request timeout'))
1014+
reject(new Error(`Request timed out after ${requestOptions.timeout}ms`))
10151015
})
10161016

10171017
if (options.body) {

apps/sim/tools/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@ export function formatRequestParams(tool: ToolConfig, params: Record<string, any
123123
}
124124
}
125125

126-
// Get timeout from params (if specified)
126+
// Get timeout from params (if specified) and validate
127+
// Must be a finite positive number, max 600000ms (10 minutes) as documented
128+
const MAX_TIMEOUT_MS = 600000
127129
const rawTimeout = params.timeout
128130
const timeout = rawTimeout != null ? Number(rawTimeout) : undefined
129131
const validTimeout =
130-
timeout != null && Number.isFinite(timeout) && timeout > 0 ? timeout : undefined
132+
timeout != null && Number.isFinite(timeout) && timeout > 0
133+
? Math.min(timeout, MAX_TIMEOUT_MS)
134+
: undefined
131135

132136
return { url, method, headers, body, timeout: validTimeout }
133137
}

0 commit comments

Comments
 (0)