-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(http): resolve 5-minute timeout limit for API block requests #2626
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
Root cause: Bun/Node.js fetch has a hardcoded 5-minute (300s) default timeout that cannot be overridden by AbortSignal.timeout(). Changes: - Add parseTimeout() function to validate user-configurable timeouts - Add timeout: false to all fetch calls to disable Bun's default limit - Use AbortSignal.timeout() for user-configurable timeout control - Add maxDuration=600 to /api/proxy and /api/workflows/[id]/execute routes - Add timeout field to RequestParams interface This allows API block requests to run up to 10 minutes as configured by the user, fixing issue simstudioai#2242. Tested: 6-minute API request completes successfully with timeout: false 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@majiayu000 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryFixed the 5-minute timeout limit for API block requests by disabling Bun/Node.js default timeout and implementing user-configurable timeout control (2-10 minutes). Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as API Block/Client
participant ProxyRoute as /api/proxy
participant ToolHandler as tools/index.ts
participant ExternalAPI as External API
Note over Client,ExternalAPI: User-configured timeout flow
Client->>ProxyRoute: POST /api/proxy<br/>{toolId, params: {timeout: 600000}}
Note over ProxyRoute: maxDuration = 600s<br/>(Next.js route config)
ProxyRoute->>ToolHandler: executeTool(toolId, params)
alt Internal Request Handler
ToolHandler->>ToolHandler: parseTimeout(params.timeout)<br/>Returns: min(timeout, 600000ms)
Note over ToolHandler: timeout: false<br/>signal: AbortSignal.timeout(timeoutMs)
ToolHandler->>ExternalAPI: fetch(url, {timeout: false, signal})
ExternalAPI-->>ToolHandler: Response (within timeout)
ToolHandler-->>ProxyRoute: Success
else Proxy Request Handler
ToolHandler->>ToolHandler: parseTimeout(params.timeout)<br/>Returns: min(timeout, 600000ms)
Note over ToolHandler: timeout: false<br/>signal: AbortSignal.timeout(timeoutMs)
ToolHandler->>ProxyRoute: fetch(/api/proxy, {timeout: false, signal})
ProxyRoute->>ExternalAPI: Forward request
ExternalAPI-->>ProxyRoute: Response (within timeout)
ProxyRoute-->>ToolHandler: Response
ToolHandler-->>ProxyRoute: Success
end
ProxyRoute-->>Client: Response with result
Note over Client,ExternalAPI: Timeout scenarios
alt Timeout Exceeded
ToolHandler->>ExternalAPI: fetch with AbortSignal
Note over ExternalAPI: Request takes > timeoutMs
ExternalAPI-xToolHandler: AbortError (signal timeout)
ToolHandler-->>Client: Error: Request timed out
end
alt GET /api/proxy (Direct Proxy)
Client->>ProxyRoute: GET /api/proxy?url=...
Note over ProxyRoute: timeout: false<br/>NO AbortSignal!<br/>Relies only on maxDuration=600s
ProxyRoute->>ExternalAPI: fetch(url, {timeout: false})
ExternalAPI-->>ProxyRoute: Response
ProxyRoute-->>Client: Response
end
|
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/app/api/proxy/route.ts, line 224-234 (link)logic: GET handler missing
AbortSignal.timeout()- only disables default timeout but provides no user-configurable timeout controlThe GET handler sets
timeout: falsebut doesn't includesignal: AbortSignal.timeout()like the POST handlers intools/index.ts. This means requests have no timeout limit except the route'smaxDurationof 600s, making timeout behavior inconsistent.
4 files reviewed, 1 comment
The @ts-expect-error directive fails in CI because it reports 'unused directive' when the error doesn't exist in the Node.js type definitions. Using @ts-ignore unconditionally ignores the type error, which is the desired behavior for Bun-specific options. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
This PR fixes the root cause of issue #2242 where API block requests timeout at 5 minutes regardless of user-configured timeout settings.
Root Cause
Bun/Node.js fetch has a hardcoded 5-minute (300 seconds) default timeout that cannot be overridden by
AbortSignal.timeout(). This is documented in Bun PR #6217.Solution
timeout: falseto all fetch calls to disable Bun/Node.js default 5-minute timeoutAbortSignal.timeout()for user-configurable timeout control (default: 2 min, max: 10 min)maxDuration = 600to/api/proxyand/api/workflows/[id]/executeroutes for Next.jsChanges
apps/sim/tools/index.tsparseTimeout()function, addtimeout: false+AbortSignal.timeout()tohandleInternalRequestandhandleProxyRequestapps/sim/app/api/proxy/route.tsmaxDuration = 600andtimeout: falseapps/sim/app/api/workflows/[id]/execute/route.tsmaxDuration = 600apps/sim/tools/http/types.tstimeout?: numberfield toRequestParamsTest Results
timeout: false+ 6-min requesttimeout: false+ 6-min requestTest Plan
timeout: falseCloses #2242
🤖 Generated with Claude Code