{"record":{"id":"53ac3993cdbb3135","repo":"mozilla/pdf.js","slug":"response-statustext","errorCode":null,"errorMessage":"response.statusText","messagePattern":"response\\.statusText","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/display/display_utils.js","lineNumber":43,"sourceCode":"import { PageViewport } from \"./page_viewport.js\";\nimport { XfaLayer } from \"./xfa_layer.js\";\n\nclass PixelsPerInch {\n  static CSS = 96.0;\n\n  static PDF = 72.0;\n\n  static PDF_TO_CSS_UNITS = this.CSS / this.PDF;\n}\n\nasync function fetchData(url, type = \"text\") {\n  if (\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n    isValidFetchUrl(url, document.baseURI)\n  ) {\n    const response = await fetch(url);\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    switch (type) {\n      case \"blob\":\n        return response.blob();\n      case \"bytes\":\n        return response.bytes();\n      case \"json\":\n        return response.json();\n    }\n    return response.text();\n  }\n\n  // The Fetch API is not supported.\n  return new Promise((resolve, reject) => {\n    const request = new XMLHttpRequest();\n    request.open(\"GET\", url, /* async = */ true);\n    request.responseType = type === \"bytes\" ? \"arraybuffer\" : type;\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/display/display_utils.js#L25-L61","documentation":"Thrown by fetchData(url, type) when a fetch() call resolves with response.ok === false. The thrown value is response.statusText — the HTTP reason phrase such as 'Not Found' or 'Forbidden'. fetchData is used internally to load CMaps, standard fonts, and other side resources via DOMBinaryDataFactory, and by direct callers fetching arbitrary PDF resources.","triggerScenarios":"A 404/403/500 on a CMap, standard-font, or other side resource URL; the server returning a non-2xx status for any URL passed to fetchData; misconfigured cMapUrl/standardFontDataUrl pointing at a path the server does not serve.","commonSituations":"Self-hosted assets missing after a deploy; reverse proxy returning 404 for the /cmaps path; auth-gated CDN returning 403; version skew between pdfjs-dist and the asset folders.","solutions":["Open the failing URL directly and fix the server config (serve the folder, return 200).","Confirm cMapUrl / standardFontDataUrl / wasmUrl paths match the installed pdfjs-dist version.","If the error is intermittent (5xx), wrap fetchData consumers in retry logic."],"exampleFix":"// before\ngetDocument({ data, cMapUrl: '/wrong-path/' });\n\n// after\ngetDocument({ data, cMapUrl: '/assets/pdfjs-4.x/cmaps/' });\n// verify: curl -I /assets/pdfjs-4.x/cmaps/GBK-EUC-H.bcmap returns 200","handlingStrategy":"try-catch","validationCode":"async function fetchOk(url, type) {\n  const res = await fetch(url);\n  if (!res.ok) throw new Error(`${url} -> HTTP ${res.status} ${res.statusText}`);\n  return type === 'bytes' ? res.bytes() : res.text();\n}","typeGuard":"null","tryCatchPattern":"try {\n  await fetchData(url, 'bytes');\n} catch (e) {\n  if (/^(Bad Request|Not Found|Forbidden|Internal Server Error)$/.test(e.message)) {\n    // surface as a config/hosting problem\n  } else throw e;\n}","preventionTips":["Verify each asset URL with curl -I before integrating.","Serve assets same-origin when possible.","Log the URL alongside the statusText for triage."],"tags":["network","http","cmaps","fonts"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}