{"record":{"id":"d1bd0c4def7aa3ab","repo":"can1357/oh-my-pi","slug":"google-browser-search-timed-out","errorCode":null,"errorMessage":"Google browser search timed out.","messagePattern":"Google browser search timed out\\.","errorType":"exception","errorClass":"SearchProviderError","httpStatus":504,"severity":"error","filePath":"packages/coding-agent/src/web/search/providers/google.ts","lineNumber":138,"sourceCode":"\tconst signal = withHardTimeout(params.signal, params.timeoutMs);\n\tconst url = buildSearchUrl(params, numResults);\n\tlet page: LoadedHtmlPage;\n\ttry {\n\t\tpage = await browserFetch(url, {\n\t\t\tfetch: params.fetch,\n\t\t\tsignal,\n\t\t\ttimeoutMs: params.timeoutMs,\n\t\t\treferer: GOOGLE_HOME_URL,\n\t\t\tbrowser: {\n\t\t\t\thomeUrl: GOOGLE_HOME_URL,\n\t\t\t\tready: { selector: \"a h3\", timeoutMs: RESULT_RENDER_TIMEOUT_MS },\n\t\t\t\tshouldFallback: candidate => blockReason(candidate) !== undefined,\n\t\t\t},\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof SearchProviderError || params.signal?.aborted) throw error;\n\t\tif (signal.aborted) {\n\t\t\tthrow new SearchProviderError(\"google\", \"Google browser search timed out.\", 504);\n\t\t}\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new SearchProviderError(\"google\", `Google browser search failed: ${message}`, 503);\n\t}\n\n\tconst blocked = blockReason(page);\n\tif (blocked === \"traffic\") {\n\t\tthrow new SearchProviderError(\n\t\t\t\"google\",\n\t\t\t\"Google blocked the browser search with an automated-traffic challenge. Try another web search provider or retry later.\",\n\t\t\t429,\n\t\t);\n\t}\n\tif (page.status < 200 || page.status >= 300) {\n\t\tthrow new SearchProviderError(\"google\", `Google HTML error (${page.status})`, page.status);\n\t}\n\tif (blocked === \"javascript\") {\n\t\tthrow new SearchProviderError(","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/web/search/providers/google.ts#L120-L156","documentation":"Thrown by callGoogleHtml when the headless-browser fetch of Google Search results does not complete before the hard timeout: the timeout AbortSignal fired and the underlying error was not already a SearchProviderError or an externally-aborted caller signal. It is wrapped with status 504 to signal an upstream/gateway timeout.","triggerScenarios":"browserFetch(url) (fetch-first with headless-browser fallback, waiting for the `a h3` result selector within RESULT_RENDER_TIMEOUT_MS) exceeds params.timeoutMs; the merged signal aborts and `signal.aborted` is true while the caller's own signal is not.","commonSituations":"Slow or resource-starved machine where the headless browser cannot render results in time; heavily throttled network; very low timeoutMs configured; Google serving a slow challenge page that never renders result anchors.","solutions":["Increase the search timeoutMs parameter (and any caller deadline).","Retry the search — slow renders are often transient.","Switch to a different web search provider (Jina, Gemini) if Google scraping remains too slow in your environment.","Check machine load / headless browser availability (browser fallback) and network latency to google.com."],"exampleFix":"// before\nawait search({ provider: \"google\", query, timeoutMs: 3000 });\n// after\nawait search({ provider: \"google\", query, timeoutMs: 15000 });","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isGoogleTimeout(e: unknown): boolean {\n  return e instanceof SearchProviderError && e.provider === 'google' && e.statusCode === 504;\n}","tryCatchPattern":"try {\n  return await search({ provider: 'google', query, timeoutMs: 15000 });\n} catch (err) {\n  if (isGoogleTimeout(err)) return await search({ provider: 'google', query, timeoutMs: 30000 });\n  throw err;\n}","preventionTips":["Set timeoutMs generously (>=10s) for scraping-based providers.","Run on hosts with enough CPU/memory for headless-browser rendering.","Implement one retry with a larger timeout on 504.","Keep a non-scraping provider as fallback for latency-sensitive paths."],"tags":["timeout","network","browser","google","search-provider"],"backgroundTag":"request-timeout","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}