vercel/ai · error · Error

google.interactions: timed out polling interaction ${interac

Error message

google.interactions: timed out polling interaction ${interactionId} after ${timeoutMs}ms.

What it means

pollGoogleInteractionUntilTerminal gives up after timeoutMs (default 30 minutes) if the background interaction never reaches a terminal status (completed/failed/cancelled/incomplete). The library errs on the long side because agent runs like deep research can take tens of minutes, so hitting this means the interaction really has not finished in that window.

Source

Thrown at packages/google/src/interactions/poll-google-interactions.ts:95

  /*
   * When the caller aborts, fire a best-effort `POST /interactions/{id}/cancel`
   * so the run stops billing on Google's side. Wrap every exit path that's
   * triggered by an abort -- the explicit `abortSignal.aborted` check, the
   * AbortError thrown by `delay()`, and any AbortError thrown by `getFromApi`.
   */
  const cancelOnServer = () =>
    cancelGoogleInteraction({ baseURL, interactionId, headers, fetch });

  try {
    while (true) {
      if (abortSignal?.aborted) {
        await cancelOnServer();
        throw new DOMException('Polling was aborted', 'AbortError');
      }

      if (Date.now() - startedAt > timeoutMs) {
        throw new Error(
          `google.interactions: timed out polling interaction ${interactionId} after ${timeoutMs}ms.`,
        );
      }

      await delay(nextDelayMs, { abortSignal });

      const {
        value: response,
        rawValue: rawResponse,
        responseHeaders,
      } = await getFromApi({
        url,
        validateUrl: false,
        headers,
        failedResponseHandler: googleFailedResponseHandler,
        successfulResponseHandler: createJsonResponseHandler(
          googleInteractionsResponseSchema,
        ),

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Raise the timeout via providerOptions.google.pollingTimeoutMs (e.g. 60 * 60 * 1000).
  2. Check the interaction status directly via GET /interactions/{id} to see if it is stuck or failed.
  3. Retry the interaction from scratch if the server-side run appears wedged.
  4. If you intentionally want a shorter wait, catch this error and fall back to polling yourself with the same interactionId.

Example fix

// before
const model = google('gemini-...', { /* default 30 min polling */ });
// after
await generateText({
  model,
  providerOptions: { google: { pollingTimeoutMs: 60 * 60 * 1000 } },
});
Defensive patterns

Strategy: retry

Try / catch

try {
  await pollGoogleInteractionUntilTerminal({ interactionId, timeoutMs: 30 * 60 * 1000 });
} catch (error) {
  if (error instanceof Error && error.message.startsWith('google.interactions: timed out')) {
    // check status via GET /interactions/{id} or restart the interaction
  } else { throw error; }
}

Prevention

When it happens

Trigger: Polling a background Google interaction whose elapsed wall-clock time since polling started exceeds timeoutMs while the status is still non-terminal — e.g. a stuck or very long agent run, or a low custom pollingTimeoutMs override.

Common situations: Long-running deep-research/agent interactions exceeding the 30-minute default; a caller setting providerOptions.google.pollingTimeoutMs too low; Google-side incidents leaving interactions in a pending state.

Understand the failure class

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/47e332ef3e64dbea. Report an issue: GitHub.