{"record":{"id":"1013f17f41ecc2f4","repo":"mozilla/pdf.js","slug":"response-statustext-1013f1","errorCode":null,"errorMessage":"${response.statusText}","messagePattern":"\\$\\{response\\.statusText\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"external/importL10n/locales.mjs","lineNumber":38,"sourceCode":"// This is used in gulpfile.js for the `importl10n` command.\n\nconst DEFAULT_LOCALE = \"en-US\";\n\nconst EXCLUDE_LANG_CODES = new Set([\"ca-valencia\", \"ja-JP-mac\"]);\n\nfunction normalizeText(s) {\n  return s.replaceAll(/\\r\\n?/g, \"\\n\").replaceAll(\"\\uFEFF\", \"\");\n}\n\nasync function downloadLanguageCodes() {\n  console.log(\"Downloading language codes...\\n\");\n\n  const ALL_LOCALES =\n    \"https://raw.githubusercontent.com/mozilla-firefox/firefox/main/browser/locales/all-locales\";\n\n  const response = await fetch(ALL_LOCALES);\n  if (!response.ok) {\n    throw new Error(response.statusText);\n  }\n  const content = await response.text();\n\n  // Remove any leading/trailing white-space.\n  const langCodes = normalizeText(content.trim()).split(\"\\n\");\n  // Remove all locales that we don't want to download below.\n  return langCodes.filter(\n    langCode => langCode !== DEFAULT_LOCALE && !EXCLUDE_LANG_CODES.has(langCode)\n  );\n}\n\nasync function downloadLanguageFiles(root, langCode) {\n  console.log(`Downloading ${langCode}...`);\n\n  // Constants for constructing the URLs. Translations are taken from the\n  // Nightly channel as those are the most recent ones.\n  const MOZ_CENTRAL_ROOT =\n    \"https://raw.githubusercontent.com/mozilla-l10n/firefox-l10n/main/\";","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/external/importL10n/locales.mjs#L20-L56","documentation":"importL10n/locales.mjs fetches the Firefox `all-locales` manifest from raw.githubusercontent.com to know which language packs to download. If the HTTP response is not OK, it throws `response.statusText` (e.g. 'Not Found', 'Too Many Requests'). This is a hard network dependency of the `gulp importl10n` task. The thrown message is whatever GitHub returned as the status reason, so it directly reflects the HTTP failure mode.","triggerScenarios":"Running `gulp importl10n` with no/slow internet; GitHub returning 404 (the mozilla-firefox/firefox repo path moved), 451/403 (region/takedown), or 429 (rate-limited); a proxy/captive portal returning a non-2xx body; DNS/TLS failure surfacing as a thrown fetch error before this line.","commonSituations":"CI behind a restricted network; local dev offline; the upstream Firefox repo was reorganized so the all-locales URL 404s; heavy automated l10n syncs hitting GitHub's anonymous rate limit.","solutions":["Retry on a clean network connection; verify `curl -I https://raw.githubusercontent.com/mozilla-firefox/firefox/main/browser/locales/all-locales` returns 200.","If rate-limited (429), wait or supply a GitHub token and adjust the fetch headers.","If the URL 404s, the upstream path changed — update the `ALL_LOCALES` constant to the current location or bump PDF.js.","Run `gulp importl10n` only when you actually need refreshed locales; commit the result so subsequent builds don't re-fetch."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Probe connectivity before running the l10n sync task.\nasync function assertReachable(url) {\n  const r = await fetch(url, { method: 'HEAD' });\n  if (!r.ok) throw new Error(`${url} unreachable: ${r.status} ${r.statusText}`);\n}","typeGuard":null,"tryCatchPattern":"async function fetchWithRetry(url, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    const r = await fetch(url);\n    if (r.ok) return r;\n    if (r.status === 429 || r.status >= 500) await new Promise(res => setTimeout(res, 1000 * (i + 1)));\n    else throw new Error(`${r.status} ${r.statusText}`);\n  }\n  throw new Error('gave up after ' + attempts + ' attempts');\n}","preventionTips":["Run `gulp importl10n` only on a clean, connected network.","Commit downloaded locales so builds don't depend on GitHub availability.","If the URL 404s, the upstream repo moved — update ALL_LOCALES or bump PDF.js."],"tags":["network","l10n","build","github","fetch"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}