{"record":{"id":"1f37e68d58301c1e","repo":"pbakaus/impeccable","slug":"source-read-failed-r-status","errorCode":null,"errorMessage":"source read failed: ${r.status}","messagePattern":"source read failed: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"skill/scripts/live-browser.js","lineNumber":6269,"sourceCode":"    // picker replaces it), so it needs evidence that the wrapper is gone: a\n    // read that answers without the marker, or a 404 (the file itself was\n    // renamed or deleted). Either kind retries on the shared budget first.\n    // A read that fails for any other reason (the server briefly away, a\n    // transient fetch error) says nothing about the wrapper; after the budget\n    // the session is kept, the user told, and the next event retries.\n    const onNoWrapper = (reason) => {\n      if (!stillActive()) return;\n      if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) { retryLater(); return; }\n      discardOrphanedSession(reason);\n    };\n    const onUnreadable = (detail) => {\n      if (!stillActive()) return;\n      if (attempt < COMPLETED_SOURCE_FALLBACK_RETRIES) { retryLater(); return; }\n      console.warn('[impeccable] Could not read source to check the variant wrapper; keeping the session: ' + detail);\n      showToast('Could not read the source file to check this session; it stays open and is checked again on the next event.', 5500);\n    };\n    fetch(url)\n      .then(r => { if (!r.ok) throw new Error('source read failed: ' + r.status); return r.text(); })\n      .then(text => {\n        if (!stillActive()) return;\n        if (sourceHasSessionWrapper(text, sessionId)) return;\n        onNoWrapper('variant wrapper missing from source');\n      })\n      .catch(err => {\n        const detail = err && err.message ? err.message : 'fetch failed';\n        if (/source read failed: 404$/.test(detail)) {\n          onNoWrapper('source file missing (404) while checking for the variant wrapper');\n          return;\n        }\n        onUnreadable(detail);\n      });\n  }\n\n  function completeSourceInjection(wrapper, sessionId, opts) {\n    recoveryWaitingForAnchor = false;\n    if (pendingVariantAnchorRetryObserver) {","sourceCodeStart":6251,"sourceCodeEnd":6287,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/skill/scripts/live-browser.js#L6251-L6287","documentation":"Thrown inside the completed-session source check when the GET of the source file from the engine server returns a non-OK status. The script reads the source to confirm the session's variant wrapper is still present; a failed read triggers the retry/fallback path that warns and keeps the session open rather than closing it. The error text prefixes the status with 'source read failed:'.","triggerScenarios":"fetch(url) of the session's source file resolves with r.ok === false after exhausting COMPLETED_SOURCE_FALLBACK_RETRIES — e.g. 404 because the source file was renamed or deleted, or 401/403 from a stale token.","commonSituations":"File moved/refactored while a completed session was still open; dev server restart invalidating TOKEN; transient localhost fetch failure on the last retry attempt.","solutions":["Check the numeric status in the thrown error/console warning: 404 → locate where the file moved and reopen the session against the new path; 401/403 → reload the tab to refresh the token","Verify the dev server is still running on PORT","Keep the session open as designed — it is re-checked on the next event; the wrapper may be verified after the file is restored","Restore or republish the source file containing the impeccable-variants wrapper for the sessionId"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"fetch(url)\n  .then(r => { if (!r.ok) throw new Error('source read failed: ' + r.status); return r.text(); })\n  .catch(err => {\n    console.warn('[impeccable] source check failed, keeping session:', err.message);\n    showToast('Session stays open; it will be re-checked on the next event.', 5500);\n  });","preventionTips":["Rely on the built-in retry/fallback: failed reads keep the session and re-check on the next event","Avoid renaming or deleting session source files while a completed session is open","Reload the tab after dev-server restarts to refresh the token before interacting","Monitor the warning text — a persistent 'source read failed: 404' means the wrapper file is truly gone"],"tags":["http","fetch","session","retry"],"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-14T05:17:10.506Z"}