Skip to content

improvement(functions): increase function block timeout to 3 min - #1641

Merged
icecrasher321 merged 4 commits into
stagingfrom
improvement/func-block-timeout
Oct 15, 2025
Merged

improvement(functions): increase function block timeout to 3 min#1641
icecrasher321 merged 4 commits into
stagingfrom
improvement/func-block-timeout

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Function block timeout for native and remote code execution increased to 3 min.

Type of Change

  • Bug fix

Testing

Manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Oct 15, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedOct 15, 2025 6:51pm

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

Increased function execution timeout from 5-10 seconds to 3 minutes (180s) across all execution paths to support longer-running user code

Key Changes:

  • Route handler: maxDuration 60s → 300s, default timeout 5s → 180s
  • Function handler: default timeout 5s → 180s
  • Tool config: DEFAULT_TIMEOUT 10s → 180s

Issues Found:

  • Critical: maxDuration (300s) exceeds execution timeout (180s), creating a 2-minute gap where the route stays open but execution has timed out

Confidence Score: 3/5

  • This PR has a configuration mismatch that needs to be resolved before merging
  • The changes correctly increase timeouts consistently across the codebase, but there's a logical error where maxDuration (300s) is set higher than the execution timeout (180s). This means functions will timeout at 3 minutes but the API route stays open for 5 minutes, potentially causing confusing behavior or resource waste.
  • apps/sim/app/api/function/execute/route.ts - maxDuration and timeout values need alignment

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/api/function/execute/route.ts5/5Increased maxDuration from 60s to 300s (5 min) and default timeout from 5s to 180s (3 min)
apps/sim/executor/handlers/function/function-handler.ts5/5Increased default timeout fallback from 5s to 180s (3 min)
apps/sim/tools/function/execute.ts5/5Updated DEFAULT_TIMEOUT constant from 10s to 180s (3 min)

Sequence Diagram

sequenceDiagram
participant Client
participant API as /api/function/execute
participant Handler as FunctionBlockHandler
participant Tool as functionExecuteTool
participant VM as Execution Environment
Note over API: maxDuration: 300s (5 min)
Client->>Handler: Execute function block
Handler->>Tool: executeTool('function_execute')
Note over Handler: timeout: 180000ms (3 min)
Tool->>API: POST /api/function/execute
Note over Tool: DEFAULT_TIMEOUT: 180000ms
API->>API: Parse request body
Note over API: Default timeout: 180000ms
alt E2B Execution (Remote)
API->>VM: executeInE2B(code, timeout)
Note over VM: Cloud sandbox execution
VM-->>API: Result/Error
else Local VM Execution
API->>VM: script.runInContext(timeout)
Note over VM: Node.js VM execution
VM-->>API: Result/Error
end
API-->>Tool: Response (success/error)
Tool-->>Handler: CodeExecutionOutput
Handler-->>Client: Execution result
Loading

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment threadapps/sim/app/api/function/execute/route.ts Outdated
waleedlatif1
waleedlatif1 previously approved these changes Oct 15, 2025
@icecrasher321
icecrasher321 merged commit fd67fd2 into stagingOct 15, 2025
3 checks passed
@blacksmith-sh

blacksmith-shBot commented Oct 15, 2025

Copy link
Copy Markdown

1 Job Failed:

CI / Test and Build / Test and Build failed on "Build application"
[...]
✓ optimizeCss
⨯ turbopackSourceMaps
Creating an optimized production build ...
✓ Finished writing to disk in 129ms
✓ Compiled successfully in 64s
Linting and checking validity of types ...
Collecting page data ...
⨯ Invalid segment configuration export detected. This can cause unexpected behavior from the configs not being applied. You should see the relevant failures in the logs above. Please fix them to continue.
error: script "build" exited with code 1
[ERROR] command finished with error: command (/home/runner/_work/sim/sim/apps/sim) /home/runner/.bun/bin/bun run build exited (1)
Tasks: 3 successful, 4 total
Cached: 0 cached, 4 total
Time: 1m36.404s Failed: sim#build
ERROR run failed: command exited (1)
error: script "build" exited with code 1
Error: Process completed with exit code 1.

Summary: 1 failed workflow
  • CI (1 job failed)

Last updated: 2025-10-15 18:55:30 UTC

@waleedlatif1
waleedlatif1 deleted the improvement/func-block-timeout branch November 6, 2025 01:25
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@icecrasher321@waleedlatif1