{"record":{"id":"d25fe496c86aa424","repo":"mastra-ai/mastra","slug":"request-timed-out-after-effectivetimeout-ms","errorCode":null,"errorMessage":"Request timed out after ${effectiveTimeout}ms","messagePattern":"Request timed out after (.+?)ms","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integrations/brightdata/src/client.ts","lineNumber":89,"sourceCode":"      if (response.status === 401 || response.status === 403) {\n        throw new Error('invalid API key or insufficient permissions');\n      }\n\n      if (response.status === 400) {\n        throw new Error(`bad request: ${responseText}`);\n      }\n\n      throw new Error(`request failed with status ${response.status}: ${responseText}`);\n    }\n\n    if (body.format === 'json') {\n      return responseText ? JSON.parse(responseText) : {};\n    }\n\n    return responseText;\n  } catch (error) {\n    if (error instanceof Error && error.name === 'AbortError') {\n      throw new Error(`Request timed out after ${effectiveTimeout}ms`);\n    }\n    throw error;\n  } finally {\n    clearTimeout(timeoutId);\n  }\n}\n\nfunction buildGoogleSearchUrl(query: string, options: SearchOptions = {}) {\n  const url = new URL('https://www.google.com/search');\n  url.searchParams.set('q', query.trim());\n  if ((options.format ?? 'json') === 'json') {\n    url.searchParams.set('brd_json', '1');\n  }\n  url.searchParams.set('hl', options.language ?? 'en');\n\n  if (options.country) {\n    url.searchParams.set('gl', options.country);\n  }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/integrations/brightdata/src/client.ts#L71-L107","documentation":"requestBrightData wraps its fetch in an AbortController with an effective timeout (client config.timeout or default). When the abort fires, fetch rejects with an AbortError, which this catch block converts into a clearer 'Request timed out after <ms>ms' error. It means Bright Data did not respond within the configured window.","triggerScenarios":"Any requestBrightData call that exceeds effectiveTimeout — slow Bright Data zone response, large result sets, network latency, or a timeout configured lower than realistic provider latency.","commonSituations":"timeout option set to a very small value; SERP queries that take several seconds under load; network egress blocked or slow from the host; provider slowdowns.","solutions":["Increase the timeout passed to getBrightDataClient({ timeout }) or the default budget to cover realistic Bright Data latency.","Retry the request — timeouts are often transient.","Check network egress/proxy configuration between the host and Bright Data.","If queries are consistently slow, reduce result size or use a faster zone."],"exampleFix":"// before\nconst client = getBrightDataClient({ apiKey, timeout: 1000 });\n// after\nconst client = getBrightDataClient({ apiKey, timeout: 30000 });","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await client.search.google(query);\n} catch (err) {\n  if (err instanceof Error && /^Request timed out after \\d+ms$/.test(err.message)) {\n    // transient — retry once with a larger client timeout or surface a degradation\n    return searchWithRetry(query);\n  }\n  throw err;\n}","preventionTips":["Set client timeout generously above p99 Bright Data latency (e.g. 30s).","Wrap search calls in retry-with-backoff; timeouts are usually transient.","Alert on sustained timeout rates — they indicate network or provider degradation.","Verify egress/proxy rules allow outbound HTTPS to Bright Data endpoints."],"tags":["timeout","network","abort"],"backgroundTag":"request-timeout","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}