Skip to content

Respect caller-supplied timeout in HTTP low-speed watchdog - #3910

Closed
DeveloperBatuhanALGUL wants to merge 1 commit into
Automattic:fix/http-low-speed-timeout-for-ai-requestsfrom
DeveloperBatuhanALGUL:feature/respect-caller-timeout-in-http-watchdog
Closed

Respect caller-supplied timeout in HTTP low-speed watchdog#3910
DeveloperBatuhanALGUL wants to merge 1 commit into
Automattic:fix/http-low-speed-timeout-for-ai-requestsfrom
DeveloperBatuhanALGUL:feature/respect-caller-timeout-in-http-watchdog

Conversation

@DeveloperBatuhanALGUL

Copy link
Copy Markdown

Builds on #3120. Reads the requested timeout from the WP_Http args passed to the http_api_curl action and honors it when the caller explicitly asks for more than 120s, capped at 280s to stay under the existing 300s outer ceiling. Callers that don't specify a custom timeout, or whose timeout equals the 300s default set by the http_request_timeout filter above, keep the unchanged 120s default. No hostname allowlist, no new constants.

The low-speed watchdog introduced in Automattic#1913 and tuned in Automattic#3120 applies a fixed 120s window to every outbound request, regardless of what the calling code asked for via wp_remote_post()'s timeout argument.

This change reads the requested timeout from the WP_Http args (the second parameter passed to the http_api_curl action, previously misnamed $url in this callback) and uses it when it exceeds 120s, capped at 280s to stay under the 300s outer ceiling already set above.

Callers that don't specify a custom timeout keep the existing 120s default introduced in Automattic#3120, unchanged. Callers that already declare a longer timeout (common in AI plugin code calling LLM APIs) now get that timeout honored instead of being overridden.

No hostname allowlist, no new constants, no change to the 300s outer cap.
@fredrikekelund
fredrikekelund deleted the branch Automattic:fix/http-low-speed-timeout-for-ai-requests July 7, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants