pbakaus/impeccable · error · Error

${r.status}

Error message

${r.status}

What it means

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.

Source

Thrown at skill/scripts/live-browser.js:6401

          showToast(
            "Variants ready. If the picked element isn't visible, retrace the path that revealed it - they'll appear automatically.",
            15000,
          );
          return;
        }
        if (liveWrapper.dataset.impeccableMode !== 'insert') {
          recoverEmptyCycling('source-fallback-empty');
        }
        return;
      }
      if (opts.orphanDiscard && !liveWrapper && sessionId === currentSessionId) {
        probeJsxWrapperForOrphan(filePath, sessionId, opts);
      }
      return;
    }
    const url = 'http://localhost:' + PORT + '/source?token=' + TOKEN + '&path=' + encodeURIComponent(filePath);
    fetch(url)
      .then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })
      .then(html => {
        const parser = new DOMParser();
        const startMark = '<!-- impeccable-variants-start ' + sessionId + ' -->';
        const endMark = '<!-- impeccable-variants-end ' + sessionId + ' -->';
        const startIdx = html.indexOf(startMark);
        const endIdx = html.indexOf(endMark);
        const block = startIdx !== -1 && endIdx !== -1 && endIdx > startIdx
          ? html.slice(startIdx + startMark.length, endIdx).trim()
          : html;
        const doc = parser.parseFromString(block, 'text/html');
        const srcWrapper = doc.querySelector('[data-impeccable-variants="' + sessionId + '"]');
        if (!srcWrapper) {
          console.warn('[impeccable] Variant wrapper not found in source file.');
          // A resumed cycling session whose wrapper is gone from source is an
          // ORPHAN: the file was edited or regenerated out from under it, so
          // no reload, HMR push, or server restart can ever complete it, and
          // the frozen picker it leaves behind used to need a manual
          // live-complete --discarded. Retry a few reads first (an agent

View on GitHub (pinned to 2bc2879276)

Solutions

  1. 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
  2. Confirm the dev server is listening on PORT and the filePath is within its served roots
  3. Reload the browser tab to re-handshake with the current server session
  4. Update the session manifest to the file's new path if the source was moved

Example fix

// before
.then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })
// after
.then(r => { if (!r.ok) throw new Error('source fetch failed: HTTP ' + r.status + ' for ' + filePath); return r.text(); })
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(url);
if (!res.ok) throw new Error('source fetch failed: HTTP ' + res.status + ' for ' + filePath);

Try / catch

fetch(url)
  .then(r => { if (!r.ok) throw new Error(r.status); return r.text(); })
  .catch(status => {
    if (status === 404) markSessionOrphaned(sessionId);
    else console.warn('[impeccable] orphan probe failed with status', status);
  });

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of pbakaus/impeccable@2bc2879276 (2026-09-08). Data as JSON: /api/errors/fe3223afde64fa69. Report an issue: GitHub.