-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(http): add configurable timeout for API block requests #2519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
… fixes, subflow resize clamping
…ribe, auth checks, new db indexes
…dioai#2481) The realtime service network policy was missing the custom egress rules section that allows configuration of additional egress rules via values.yaml. This caused the realtime pods to be unable to connect to external databases (e.g., PostgreSQL on port 5432) when using external database configurations. The app network policy already had this section, but the realtime network policy was missing it, creating an inconsistency and preventing the realtime service from accessing external databases configured via networkPolicy.egress values. This fix adds the same custom egress rules template section to the realtime network policy, matching the app network policy behavior and allowing users to configure database connectivity via values.yaml.
…rovements, additional kb tag types
Adds timeout parameter to HTTP request tool and API block: - Default timeout: 120000ms (2 minutes) - Max timeout: 600000ms (10 minutes) - User-friendly error message on timeout This allows users to configure longer timeouts for slow API endpoints. Fixes simstudioai#2242
|
@majiayu000 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryAdded configurable timeout support to API block requests, solving issue #2242 where API blocks were timing out on slow endpoints. Users can now set custom timeouts up to 10 minutes (default: 2 minutes). Key Changes
Minor Issues
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant APIBlock
participant HTTPRequest
participant InternalHandler
participant ProxyHandler
participant ExternalAPI
User->>APIBlock: Configure timeout (ms)
APIBlock->>HTTPRequest: Execute with params.timeout
alt Internal Route
HTTPRequest->>InternalHandler: handleInternalRequest()
InternalHandler->>InternalHandler: Parse timeout (default: 120s, max: 600s)
InternalHandler->>InternalHandler: Create AbortSignal.timeout(timeoutMs)
InternalHandler->>ExternalAPI: fetch(url, {signal})
alt Request completes in time
ExternalAPI-->>InternalHandler: Response
InternalHandler-->>HTTPRequest: Success
else Request times out
ExternalAPI-->>InternalHandler: TimeoutError
InternalHandler->>InternalHandler: Log timeout error
InternalHandler-->>HTTPRequest: "Request timed out after Xms"
end
else Proxy Route
HTTPRequest->>ProxyHandler: handleProxyRequest()
ProxyHandler->>ProxyHandler: Parse timeout (default: 120s, max: 600s)
ProxyHandler->>ProxyHandler: Create AbortSignal.timeout(timeoutMs)
ProxyHandler->>ExternalAPI: fetch(proxyUrl, {signal})
alt Request completes in time
ExternalAPI-->>ProxyHandler: Response
ProxyHandler-->>HTTPRequest: Success
else Request times out
ExternalAPI-->>ProxyHandler: TimeoutError
ProxyHandler->>ProxyHandler: Log timeout error
ProxyHandler-->>HTTPRequest: "Request timed out after Xms"
end
end
HTTPRequest-->>APIBlock: Result
APIBlock-->>User: Display result or timeout error
|
The previous implementation only added timeout to handleInternalRequest, but external API requests go through handleProxyRequest which was missing the timeout logic. This caused the proxy fetch to use default timeout instead of the user-configured value. - Add timeout parsing logic to handleProxyRequest - Add AbortSignal.timeout to proxy fetch call - Add user-friendly timeout error message Fixes the issue reported by @ARNOLDAJEE where 600000ms timeout setting was not taking effect for external API requests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@ARNOLDAJEE I've identified and fixed the issue! Root Cause: The timeout was only implemented in Fix: Added the same timeout logic to
The fix has been pushed. Could you please test again after this PR is merged? |
Add comprehensive unit tests to verify: - Numeric timeout parsing - String timeout parsing - MAX_TIMEOUT_MS cap (600000ms) - DEFAULT_TIMEOUT_MS fallback (120000ms) - Invalid value handling - AbortSignal.timeout integration - Timeout error identification 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (1)
-
apps/sim/tools/index.ts, line 653-663 (link)style: timeout parsing logic duplicated in
handleInternalRequest(lines 653-663) andhandleProxyRequest(lines 898-908)Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
6 files reviewed, 1 comment
Summary
Test plan
Fixes #2242