decolua/9router · error · Error

Google translate fetch failed: ${res.status}

Error message

Google translate fetch failed: ${res.status}

What it means

The Google Translate (unofficial) TTS token scraper fetches https://translate.google.com/ to extract session params (`f.sid`, `bl`) from the page HTML. It throws this when the page fetch returns a non-2xx HTTP status. The token is cached and refreshed every REFRESH_MS, so this occurs on cold start and cache expiry.

Source

Thrown at open-sse/handlers/ttsProviders/googleTts.js:12

// Google Translate TTS (no auth) — scrape token + batchexecute RPC
import { UA } from "./_base.js";

const REFRESH_MS = 11 * 60 * 1000;
const cache = { token: null, tokenTime: 0 };
let _idx = 0;

async function getToken() {
  const now = Date.now();
  if (cache.token && now - cache.tokenTime < REFRESH_MS) return cache.token;
  const res = await fetch("https://translate.google.com/", { headers: { "User-Agent": UA } });
  if (!res.ok) throw new Error(`Google translate fetch failed: ${res.status}`);
  const html = await res.text();
  const fSid = html.match(/"FdrFJe":"(.*?)"/)?.[1];
  const bl = html.match(/"cfb2h":"(.*?)"/)?.[1];
  if (!fSid || !bl) throw new Error("Failed to parse Google token");
  cache.token = { "f.sid": fSid, bl };
  cache.tokenTime = now;
  return cache.token;
}

export default {
  noAuth: true,
  async synthesize(text, model) {
    const lang = model || "en";
    const token = await getToken();
    const cleanText = text.replace(/[@^*()\\/\-_+=><"'\u201c\u201d\u3010\u3011]/g, " ").replaceAll(", ", ". ");
    const rpcId = "jQ1olc";
    const reqId = (++_idx * 100000) + Math.floor(1000 + Math.random() * 9000);
    const query = new URLSearchParams({

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Check the captured `res.status` in the message to identify the HTTP cause (429 = rate limited, 403 = blocked)
  2. Retry after backoff — the cache means transient blocks self-heal once REFRESH_MS passes or a retry succeeds
  3. Run from a residential/different IP or add proxy support; avoid hammering the endpoint
  4. Consider an official TTS provider (or a maintained google-tts-api library) since this unofficial scraping path is inherently fragile
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try { await googleTts(text); } catch (e) { if (e.message.startsWith('Google translate fetch failed')) { const code = parseInt(e.message.match(/(\d+)$/)?.[1]); if (code === 429 || code >= 500) await sleep(backoff); else throw e; } }

Prevention

When it happens

Trigger: The GET to translate.google.com returns 4xx/5xx — e.g. 429 from rate limiting the scraper, 503 from regional blocking, or network/proxy interception returning an error status.

Common situations: Datacenter IPs being rate-limited or blocked by Google; no proper cookies/consent in a region requiring consent; corporate proxy returning error pages; Google deploying bot defenses against the translate page.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/6855413ad8df0fb0. Report an issue: GitHub.