{"record":{"id":"fe3223afde64fa69","repo":"pbakaus/impeccable","slug":"r-status","errorCode":null,"errorMessage":"${r.status}","messagePattern":"\\$\\{r\\.status\\}","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skill/scripts/live-browser.js","lineNumber":6401,"sourceCode":"          showToast(\n            \"Variants ready. If the picked element isn't visible, retrace the path that revealed it - they'll appear automatically.\",\n            15000,\n          );\n          return;\n        }\n        if (liveWrapper.dataset.impeccableMode !== 'insert') {\n          recoverEmptyCycling('source-fallback-empty');\n        }\n        return;\n      }\n      if (opts.orphanDiscard && !liveWrapper && sessionId === currentSessionId) {\n        probeJsxWrapperForOrphan(filePath, sessionId, opts);\n      }\n      return;\n    }\n    const url = 'http://localhost:' + PORT + '/source?token=' + TOKEN + '&path=' + encodeURIComponent(filePath);\n    fetch(url)\n      .then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })\n      .then(html => {\n        const parser = new DOMParser();\n        const startMark = '<!-- impeccable-variants-start ' + sessionId + ' -->';\n        const endMark = '<!-- impeccable-variants-end ' + sessionId + ' -->';\n        const startIdx = html.indexOf(startMark);\n        const endIdx = html.indexOf(endMark);\n        const block = startIdx !== -1 && endIdx !== -1 && endIdx > startIdx\n          ? html.slice(startIdx + startMark.length, endIdx).trim()\n          : html;\n        const doc = parser.parseFromString(block, 'text/html');\n        const srcWrapper = doc.querySelector('[data-impeccable-variants=\"' + sessionId + '\"]');\n        if (!srcWrapper) {\n          console.warn('[impeccable] Variant wrapper not found in source file.');\n          // A resumed cycling session whose wrapper is gone from source is an\n          // ORPHAN: the file was edited or regenerated out from under it, so\n          // no reload, HMR push, or server restart can ever complete it, and\n          // the frozen picker it leaves behind used to need a manual\n          // live-complete --discarded. Retry a few reads first (an agent","sourceCodeStart":6383,"sourceCodeEnd":6419,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/skill/scripts/live-browser.js#L6383-L6419","documentation":"Thrown when fetching an HTML source file from the engine server's /source endpoint (during orphan JSX-wrapper probing) returns a non-OK status. Note this throw uses `throw new Error(r.status)` — passing a number, so the message is the bare numeric status string. The subsequent DOMParser logic then searches for the session's start/end comment markers.","triggerScenarios":"fetch('http://localhost:PORT/source?token=...&path=filePath') resolves with r.ok === false: the file was deleted or renamed (404), the token is stale after a dev-server restart (401/403), or the path is outside the server's allowed roots (403).","commonSituations":"Checking whether an old session's JSX wrapper still exists after a refactor removed or moved the file; browsing a tab left open across a server restart; wrong path casing/extension in the manifest.","solutions":["Check the bare-number status: 404 → the file is gone, treat the session as orphaned and republish or close it; 401/403 → reload the page for a fresh token","Confirm the dev server is listening on PORT and the filePath is within its served roots","Reload the browser tab to re-handshake with the current server session","Update the session manifest to the file's new path if the source was moved"],"exampleFix":"// before\n.then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })\n// after\n.then(r => { if (!r.ok) throw new Error('source fetch failed: HTTP ' + r.status + ' for ' + filePath); return r.text(); })","handlingStrategy":"try-catch","validationCode":"const res = await fetch(url);\nif (!res.ok) throw new Error('source fetch failed: HTTP ' + res.status + ' for ' + filePath);","typeGuard":null,"tryCatchPattern":"fetch(url)\n  .then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })\n  .catch(status => {\n    if (status === 404) markSessionOrphaned(sessionId);\n    else console.warn('[impeccable] orphan probe failed with status', status);\n  });","preventionTips":["Treat 404 as 'wrapper gone' — the session is orphaned and can be cleaned up","Refresh the token by reloading the page if you see 401/403 after a server restart","Keep file paths in the manifest in sync when refactoring","Log the path alongside the status; a bare numeric Error makes diagnosis harder"],"tags":["http","fetch","jsx","orphan"],"backgroundTag":"http-error-response","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}