Translating large jobs via the ai provider often fails

Created on 19 September 2025, 17 days ago

Problem/Motivation

Translating large TMGMT jobs or even ai_translate via the ai provider often fails with

cURL error 28: Operation timed out after 60003 milliseconds

because the base HTTP client in AiProviderClientBase hardcodes a 60s timeout.

ResponseText: The website encountered an unexpected error. Try again later.Drupal\ai\Exception\AiRequestErrorException: Error invoking model response: cURL error 28: Operation timed out after 6000 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.openai.com/v1/chat/completions in Drupal\ai\Plugin\ProviderProxy->wrapperCall() (line 309 of modules/contrib/ai/src/Plugin/ProviderProxy.php). Drupal\ai\Plugin\ProviderProxy->__call() (Line: 279)

This aborts AJAX batch calls and interrupts translations that legitimately need more time (e.g., multi-field jobs, slow upstream responses).

Steps to reproduce (required for bugs, but not feature requests)

Configure an AI provider (e.g., OpenAI) and set up an ai_tmgmt translator or any other translation provider for that matter.
Create a translation job with several long HTML fields, the more complex markup the better for testing.
Run the job via the UI, allowing the batch process to operate for more than 60s.
Observe that the batch request fails with HTTP 500 / AiRequestErrorException referencing cURL error 28.

Proposed resolution

Introduce a configurable timeout so site owners can raise the limit (or disable it) without patching core code or overriding it in the settings.php would be nice. Considering this type of work really depends on the model as well (meaning some models might take a long time to respond, eg, thinking models)

🐛 Bug report
Status

Active

Version

1.2

Component

...to be triaged

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024