diff --git a/crates/core/src/host/instance_env.rs b/crates/core/src/host/instance_env.rs index a47f035cf34..0efcd59014c 100644 --- a/crates/core/src/host/instance_env.rs +++ b/crates/core/src/host/instance_env.rs @@ -970,12 +970,16 @@ impl InstanceEnv { /// Default timeout for HTTP requests performed by [`InstanceEnv::http_request`]. /// -/// Value chosen arbitrarily by pgoldman 2025-11-18, based on little more than a vague guess. -const HTTP_DEFAULT_TIMEOUT: Duration = Duration::from_millis(500); +/// Applied when the module does not specify a timeout. +/// 30 seconds is generous enough for most external API calls (including LLM APIs) +/// without silently hanging forever on a broken endpoint. +const HTTP_DEFAULT_TIMEOUT: Duration = Duration::from_secs(30); /// Maximum timeout for HTTP requests performed by [`InstanceEnv::http_request`]. /// /// If the user requests a timeout longer than this, we will clamp to this value. -const HTTP_MAX_TIMEOUT: Duration = Duration::from_secs(10); +/// 180 seconds accommodates long-running LLM and AI API calls, +/// which routinely take 30-120 seconds for complex requests. +const HTTP_MAX_TIMEOUT: Duration = Duration::from_secs(180); const BLOCKED_HTTP_ADDRESS_ERROR: &str = "refusing to connect to private or special-purpose addresses"; struct FilteredDnsResolver; diff --git a/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md b/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md index b769b55a4b4..97cab79bb07 100644 --- a/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md +++ b/docs/docs/00200-core-concepts/00200-functions/00400-procedures.md @@ -873,15 +873,15 @@ SPACETIMEDB_PROCEDURE(Unit, get_request_with_short_timeout, ProcedureContext ctx } ``` -:::note -All timeouts are clamped to a maximum of 500ms by the host. -::: - Procedures can't send requests at the same time as holding open a [transaction](#accessing-the-database). +:::note +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. +::: + ## Calling Reducers from Procedures Procedures can call reducers by invoking them within a transaction block. The reducer function runs within the transaction context: