Problem/Motivation

Many times, when using a Gemini 2.5 Flash or Gemini 2.5 Pro, cURL throws an error:

[error] AI migration failed for url https://accessibility.civicactions.com/posts/delivering-digital-first-turning-21st-century-idea-into-action: Error invoking model response: cURL error 28: Operation timed out after 60002 milliseconds with 0 bytes received (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://generativelanguage.googleapis.com/v1/models/gemini-2.5-flash:generateContent

In theses instances, the AI query does not complete, and content is not migrated. Because the AI query can happen twice during each url's migration, it's possible to get an error during the "count" part of the migration, and then get a success during the "actual" migration. In that case, the migration would be migrated anyway.

cURL's default timeout is 300 seconds, and we're seeing it timeout at 60s. So, the setting is getting configured somewhere. I suspect somewhere in the Gemini provider module or in the AI module itself.

Please find where the timeout is getting configured and override it in our module, if possible.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

majorrobot created an issue. See original summary.

dmundra’s picture

Status: Active » Reviewed & tested by the community

Thank you @majorrobot for figuring it out. Approved the MR

majorrobot’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @dmundra! Merged.

FYI, it turns out this was addressed in AI core: https://www.drupal.org/project/ai/issues/3479159. It looks like you can add the config when you create the provider instance.

 $provider = $this->aiProviderPluginManager->createInstance($this->providerId, [
      'model_id' => $this->modelId,
      'http_client_options' => [
        'timeout' => 300,
      ],
    ]);

For posterity:

QA Steps:
This assumes you have already added a Gemini API key to your Drupal instance.

  • Log in as an admin.
  • Go to /admin/config/ai/settings.
  • Under Chat, set the Default Provider to Gemini and the Default Model to Gemini 2.5 Flash.
  • Rollback any previous imports: ddev drush migrate:rollback simple_content_migration
  • ddev drush cr
  • Import: ddev drush migrate:import simple_content_migration
  • Confirm that 2 items imported and you do not receive a curl error.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

dmundra’s picture

Status: Fixed » Closed (fixed)