pbakaus/impeccable · warning

[impeccable] failed to fetch pending count:

Error message

[impeccable] failed to fetch pending count:

What it means

The in-page live script failed to fetch the pending manual-edit count from the local live server (/manual-edit-stash). The fetch or JSON parse threw and the failure is only warned; the pending pill counter is simply not updated.

Solutions

  1. Confirm the live server on the given PORT is running; restart the live session and reload the page.
  2. Check that the token matches the current server session (reload the page to get a fresh TOKEN).
  3. Open the URL manually in devtools network tab to see the actual status/response.
  4. Ignore if transient: the counter refreshes on the next successful poll.

Example fix

// before
const res = await fetch(url); const data = await res.json();
// after (surface status before parsing)
const res = await fetch(url);
if (!res.ok) { console.warn('[impeccable] pending count HTTP', res.status); return; }
const data = await res.json();
Defensive patterns

Strategy: retry

Validate before calling

async function serverUp(port) {
  try { const r = await fetch('http://localhost:' + port + '/healthz'); return r.ok; } catch { return false; }
}

Try / catch

try {
  const res = await fetch(url);
  if (!res.ok) throw new Error('HTTP ' + res.status);
  const data = await res.json();
  updatePendingCounter(data.count || 0);
} catch (err) {
  console.warn('[impeccable] failed to fetch pending count:', err);
}

Prevention

When it happens

Trigger: The browser page calls http://localhost:<PORT>/manual-edit-stash?token=...&pageUrl=...; network error, non-OK response falling through, or res.json() throwing leads to the catch at skill/scripts/live-browser.js:4109.

Common situations: Live dev server was restarted or stopped while the page stayed open; wrong/changed TOKEN after a server restart; page URL path changed; localhost port conflict.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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

Appendix: source

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

    if (previousCount <= 0) playPendingIntroAnimation();
  }

  function maybeShowFirstSaveToast() {
    if (!firstSaveOfSession) return;
    firstSaveOfSession = false;
    showToast('Saved. Click "Apply copy edits" to write changes.', 4500);
  }

  async function fetchPendingCount() {
    try {
      const res = await fetch(
        'http://localhost:' + PORT + '/manual-edit-stash?token=' + encodeURIComponent(TOKEN) + '&pageUrl=' + encodeURIComponent(location.pathname),
      );
      if (!res.ok) return;
      const data = await res.json();
      updatePendingCounter(data.count || 0);
    } catch (err) {
      console.warn('[impeccable] failed to fetch pending count:', err);
    }
  }

  async function onPendingPillClick() {
    const count = parseInt(pendingPillEl?.dataset.count || '0', 10);
    if (count <= 0 || pendingApplyInFlight) return;
    const ok = confirm('Apply ' + count + ' copy edit' + (count === 1 ? '' : 's') + ' to source?');
    if (!ok) return;
    let waitForSseCompletion = false;
    resetManualApplyProgress(count);
    setPendingApplyLoading(true, count);
    try {
      const res = await fetch(
        'http://localhost:' + PORT + '/manual-edit-commit?token=' + encodeURIComponent(TOKEN) + '&pageUrl=' + encodeURIComponent(location.pathname) + '&async=1',
        { method: 'POST', keepalive: true },
      );
      if (!res.ok) {
        const errBody = await res.json().catch(() => ({}));

View on GitHub (pinned to f2c7051853)