Skip to content

Commit cd88beb

Browse files
Bump HTTP procedure timeouts (500ms/10s → 30s/180s) and fix docs (#4630)
Relates to #4608 ## Timeout bump The previous defaults for HTTP requests in procedures were far too restrictive: | | Before | After | |---|---|---| | Default (no timeout set) | 500ms | **30s** | | Maximum (clamp ceiling) | 10s | **180s** | Users are hitting the 10s ceiling when calling LLM APIs (OpenAI, Gemini, etc.) from procedures. These APIs routinely take 30-120 seconds, especially for image/vision models. The 500ms default also caused silent failures for users who did not explicitly set a timeout. ### Comparable platforms - **Supabase Edge Functions**: 150s (free) / 400s (pro) total execution - **Vercel Functions**: 10s (hobby) / 60s (pro) / 300s (enterprise) total - **Convex actions**: 120s limit - **AWS Lambda**: up to 15 min total - **Firebase/GCF**: 60s default, configurable up to 540s Most platforms do not separately clamp outbound HTTP timeouts at all. ## Docs fix The procedures docs page had a note inside the C++ tab only that said `All timeouts are clamped to a maximum of 500ms by the host`. This was wrong (the max was 10s, not 500ms) and buried in the wrong place (applies to all languages, not just C++). Moved the note outside the language tabs and updated the values to match the new code. ### Changes - `crates/core/src/host/instance_env.rs`: `HTTP_DEFAULT_TIMEOUT` 500ms → 30s, `HTTP_MAX_TIMEOUT` 10s → 180s - `docs/.../procedures.md`: Fix and relocate timeout note --------- Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
1 parent a39b81b commit cd88beb

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

crates/core/src/host/instance_env.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -970,12 +970,16 @@ impl InstanceEnv {
970970

971971
/// Default timeout for HTTP requests performed by [`InstanceEnv::http_request`].
972972
///
973-
/// Value chosen arbitrarily by pgoldman 2025-11-18, based on little more than a vague guess.
974-
const HTTP_DEFAULT_TIMEOUT: Duration = Duration::from_millis(500);
973+
/// Applied when the module does not specify a timeout.
974+
/// 30 seconds is generous enough for most external API calls (including LLM APIs)
975+
/// without silently hanging forever on a broken endpoint.
976+
const HTTP_DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);
975977
/// Maximum timeout for HTTP requests performed by [`InstanceEnv::http_request`].
976978
///
977979
/// If the user requests a timeout longer than this, we will clamp to this value.
978-
const HTTP_MAX_TIMEOUT: Duration = Duration::from_secs(10);
980+
/// 180 seconds accommodates long-running LLM and AI API calls,
981+
/// which routinely take 30-120 seconds for complex requests.
982+
const HTTP_MAX_TIMEOUT: Duration = Duration::from_secs(180);
979983
const BLOCKED_HTTP_ADDRESS_ERROR: &str = "refusing to connect to private or special-purpose addresses";
980984

981985
struct FilteredDnsResolver;

docs/docs/00200-core-concepts/00200-functions/00400-procedures.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,15 +873,15 @@ SPACETIMEDB_PROCEDURE(Unit, get_request_with_short_timeout, ProcedureContext ctx
873873
}
874874
```
875875
876-
:::note
877-
All timeouts are clamped to a maximum of 500ms by the host.
878-
:::
879-
880876
Procedures can't send requests at the same time as holding open a [transaction](#accessing-the-database).
881877
882878
</TabItem>
883879
</Tabs>
884880
881+
:::note
882+
If no timeout is specified, HTTP requests default to 30 seconds. User-specified timeouts are clamped to a maximum of 180 seconds by the host.
883+
:::
884+
885885
## Calling Reducers from Procedures
886886
887887
Procedures can call reducers by invoking them within a transaction block. The reducer function runs within the transaction context:

0 commit comments

Comments
 (0)