{"record":{"id":"ccf997d3cb1237c9","repo":"mozilla/pdf.js","slug":"jpegimage-parse-no-frame-data-found","errorCode":null,"errorMessage":"JpegImage.parse - no frame data found.","messagePattern":"JpegImage\\.parse - no frame data found\\.","errorType":"exception","errorClass":"JpegError","httpStatus":null,"severity":"error","filePath":"src/core/jpg.js","lineNumber":1177,"sourceCode":"                \"without finding an EOI marker (0xFFD9).\"\n            );\n            break markerLoop;\n          }\n          throw new JpegError(\n            \"JpegImage.parse - unknown marker: \" + fileMarker.toString(16)\n          );\n      }\n\n      if (offset < maxOffset) {\n        fileMarker = view.getUint16(offset);\n        offset += 2;\n      } else {\n        fileMarker = 0;\n      }\n    }\n\n    if (!frame) {\n      throw new JpegError(\"JpegImage.parse - no frame data found.\");\n    }\n    this.width = frame.samplesPerLine;\n    this.height = frame.scanLines;\n    this.jfif = jfif;\n    this.adobe = adobe;\n    this.components = [];\n    for (const component of frame.components) {\n      // Prevent errors when DQT markers are placed after SOF{n} markers,\n      // by assigning the `quantizationTable` entry after the entire image\n      // has been parsed (fixes issue7406.pdf).\n      const quantizationTable = quantizationTables[component.quantizationId];\n      if (quantizationTable) {\n        component.quantizationTable = quantizationTable;\n      }\n\n      this.components.push({\n        index: component.index,\n        output: buildComponentData(frame, component),","sourceCodeStart":1159,"sourceCodeEnd":1195,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/jpg.js#L1159-L1195","documentation":"Thrown at the end of parse() if the marker loop completed without ever encountering a SOF (Start-Of-Frame) marker. Without a frame header there is no dimension/component/precision information, so the image cannot be decoded. The `frame` variable remained undefined.","triggerScenarios":"parse() reaches the end of marker processing (EOI or end-of-data) with frame still undefined. Means no 0xFFC0/C1/C2 marker existed. Could happen if the stream is all tables (DQT/DHT) and metadata but no actual image frame, or is severely truncated.","commonSituations":"A JPEG stream that is actually just headers/tables (e.g. a thumbnail or a fragment), a truncated file missing the SOF, or non-JPEG data that happened to start with 0xFFD8 but contains no frame.","solutions":["Confirm the stream contains a SOFn marker via hex inspection.","Check the stream isn't truncated — ensure /Length and fetch delivered all bytes.","Catch JpegError and render a placeholder for the missing image."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// crude check that a SOF marker exists in the data\nfunction hasFrame(data) {\n  for (let i = 0; i < data.length - 1; i++) {\n    if (data[i] === 0xff && (data[i+1] === 0xc0 || data[i+1] === 0xc1 || data[i+1] === 0xc2)) return true;\n  }\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try { jpegImg.parse(data); }\ncatch (e) { if (e.name === 'JpegError' && /no frame data/.test(e.message)) { /* no SOF, placeholder */ } else throw e; }","preventionTips":["Confirm the JPEG contains a SOFn marker before parsing.","Ensure the stream isn't truncated (verify /Length and full fetch).","Catch JpegError and render a placeholder for frameless fragments."],"tags":["jpeg","format-validation","image-decoding","corrupt-data"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}