fix(tools): bound internal tool calls by the plan deadline, not Bun's fetch default - #6547
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds Internal route requests in Reviewed by Cursor Bugbot for commit 0f421b1. Configure here. |
Greptile SummaryThe PR prevents Bun’s default transport timeout from undercutting the plan-aware deadline on internal tool requests.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/core/utils/fetch-deadline.ts | Introduces a focused helper for disabling Bun’s transport timeout and a classifier for recognized transport failures. |
| apps/sim/lib/core/utils/fetch-deadline.test.ts | Covers helper output, immutability, init preservation, and timeout-error classification. |
| apps/sim/tools/index.ts | Applies the helper to internal tool requests while retaining the existing AbortController deadline and adds contextual transport errors. |
Sequence Diagram
sequenceDiagram
participant Executor as Tool executor
participant Timer as Plan deadline timer
participant Fetch as Bun fetch
participant Route as Internal route
Executor->>Timer: Arm AbortController with plan-aware timeout
Executor->>Fetch: "Request with signal and timeout=false"
Fetch->>Route: Internal tool request
alt Route responds before deadline
Route-->>Fetch: Response
Fetch-->>Executor: Tool response
else Plan deadline expires
Timer->>Fetch: Abort signal
Fetch-->>Executor: AbortError
else Transport fails
Fetch-->>Executor: TimeoutError or fetch failed
Executor->>Executor: Add tool, elapsed-time, and deadline context
end
Reviews (2): Last reviewed commit: "fix(tools): disarm Bun's fetch idle time..." | Re-trigger Greptile
…c deadline
Bun 1.3.14 ignores a positive numeric `timeout` on fetch and honors only the
boolean/zero form, so passing the plan deadline through changed nothing and
internal tool calls still died at the 300s default. Verified against the pinned
runtime: `{ timeout: 1000 }` does not abort a request that takes 3s to answer,
and `BUN_CONFIG_HTTP_IDLE_TIMEOUT` has no effect either — both are `main`-only.
The caller on this path already arms an AbortController with the plan timeout,
so the transport timer is disarmed rather than re-negotiated, leaving one
enforcement point instead of two that disagree.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
d8509ff to
3d10803
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 3d10803. Configure here.
Replaces the inferred note with the numbers from a probe against the pinned runtime: no option dies at 300028ms, timeout:false survives 310031ms, and a numeric timeout is ignored. Also records that bun-types@1.3.14 does not declare the option even though the runtime honors it, which is why the interface is declared locally. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Summary
Every internal tool call was capped at 5 minutes regardless of plan.
tools/index.tscomputes a plan-aware deadline for internal routes —getMaxExecutionTimeout(), 3000s on enterprise — and hands it to its ownAbortController. It never handed it to the transport. So Bun's fetch idle timer governed instead, and its default is 300s.Bun's own source describes that timer as re-arming on writes and body-phase reads but not on response-header reads, making it "an absolute deadline for the header block to complete." An
AbortSignalcannot raise it. Any route that computes before it answers therefore dies at five minutes no matter what deadline was computed for it.Reproduced in production on a workflow whose Function block runs a 15–40 minute sandboxed engine: all 16 parallel shards failed together at 300.5s with a bare
fetch failed. An earlier run of the same workflow failed at 250.9s withTimeoutError: The operation timed out.Type of Change
Testing
N/A
Checklist