Skip to content

Commit d57fa9f

Browse files
committed
fix: validate timeout is positive number
Negative timeout values would cause immediate request abort since JavaScript treats negative setTimeout delays as 0.
1 parent e2023dc commit d57fa9f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/sim/tools/utils.ts

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

126-
// Get timeout from params (if specified) and ensure it's a number
126+
// Get timeout from params (if specified) and ensure it's a valid positive number
127127
// The short-input subBlock returns a string, so we need to convert it
128128
const rawTimeout = params.timeout
129129
const timeout = rawTimeout != null ? Number(rawTimeout) : undefined
130+
const validTimeout =
131+
timeout != null && !Number.isNaN(timeout) && timeout > 0 ? timeout : undefined
130132

131-
return { url, method, headers, body, timeout: Number.isNaN(timeout) ? undefined : timeout }
133+
return { url, method, headers, body, timeout: validTimeout }
132134
}
133135

134136
/**

0 commit comments

Comments
 (0)