{"record":{"id":"bb0f1f16963ad837","repo":"pbakaus/impeccable","slug":"snapshot-did-not-parse","errorCode":null,"errorMessage":"snapshot did not parse","messagePattern":"snapshot did not parse","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browser-bundle/60-offscreen.js","lineNumber":141,"sourceCode":"\n  // addVisualContrastResult over id-keyed groups: the two decisions are the\n  // core's; this only keeps the map.\n  function addVisualContrastResult(wasm, groups, result) {\n    const elId = wasm.visual_contrast_result_el(JSON.stringify(result));\n    if (!elId) return 0;\n    let group = groups.find(g => g.el === elId);\n    const existing = group ? group.findings : [];\n    const finding = JSON.parse(wasm.visual_contrast_result_finding(elId, JSON.stringify(existing), JSON.stringify(result)));\n    if (!finding) return 0;\n    if (group) group.findings.push(finding);\n    else groups.push({ el: elId, findings: [finding] });\n    return elId;\n  }\n\n  async function runScan(session, msg) {\n    const wasm = await coreReady();\n    const n = wasm.snapshot_load(msg.snapshot);\n    if (n === 0xFFFFFFFF) throw new Error('snapshot did not parse');\n    const config = msg.config || {};\n    const IO = createOffscreenVisualIO(wasm, session);\n    const vc = createVisualContrast(IO);\n    const t0 = performance.now();\n    const collected = JSON.parse(await IO.core('collect_browser_findings', configJson(config)));\n    const groups = collected.groups;\n    const stats = { elements: n, coreMs: performance.now() - t0, unknownStyleProps: JSON.parse(wasm.snapshot_unknown_style_props()) };\n    await ask(session, {\n      stage: 'findings',\n      groups,\n      pageLevel: collected.pageLevel,\n      serialized: serialize(wasm, groups),\n      stats,\n    });\n    const options = config;\n    // An ignoreFiles-waived page (config.skipScan) answers every stage empty:\n    // the core already emptied the collect pass, and the visual pass would\n    // repopulate it, so it is skipped with everything else (mirrors","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/browser-bundle/60-offscreen.js#L123-L159","documentation":"runScan in the offscreen document loads the message's snapshot into the WASM core via snapshot_load(); a return value of 0xFFFFFFFF (u32 -1 sentinel) means the snapshot JSON failed to parse, and the function throws this error. No scan is started on invalid input.","triggerScenarios":"Sending a runScan/scan message to the offscreen document whose msg.snapshot is malformed JSON, truncated, or produced by an incompatible snapshot version.","commonSituations":"Version skew between the content-script snapshot serializer and the bundled WASM core; passing a stale or manually edited snapshot string; a capture that failed silently upstream.","solutions":["Regenerate the snapshot with the current impeccableSnapshotCapture and resend the scan message","Check that the extension's content script and offscreen bundle are the same version (reload/reinstall the extension)","Log msg.snapshot before sending and validate it is well-formed JSON","Guard the sender: only pass result of a successful capture (no .error field)"],"exampleFix":"// before\nport.postMessage({ type: 'scan', snapshot: maybeSnapshot });\n// after\nif (!maybeSnapshot || typeof maybeSnapshot !== 'string') throw new Error('no snapshot');\nJSON.parse(maybeSnapshot); // throws early if malformed\nport.postMessage({ type: 'scan', snapshot: maybeSnapshot });","handlingStrategy":"validation","validationCode":"function snapshotIsParsable(s) {\n  if (typeof s !== 'string' || !s) return false;\n  try { JSON.parse(s); return true; } catch { return false; }\n}\n// call before posting the scan message","typeGuard":"function isSnapshotMsg(msg) { return msg && typeof msg.snapshot === 'string' && snapshotIsParsable(msg.snapshot); }","tryCatchPattern":"try {\n  await runScan(session, msg);\n} catch (e) {\n  if (e.message === 'snapshot did not parse') {\n    // request a fresh capture from the content script and retry once\n  }\n}","preventionTips":["Validate snapshot JSON at the sender before posting to the offscreen document","Keep content-script serializer and WASM core versions in lockstep","Never persist/replay snapshots across extension versions","Log a short prefix of the snapshot on failure for diagnosis"],"tags":["snapshot","json","wasm"],"backgroundTag":"json-parse-error","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}