pbakaus/impeccable · warning

[impeccable] Svelte component abort cleanup failed:

Error message

[impeccable] Svelte component abort cleanup failed:

What it means

abortSvelteComponentInjection runs when a svelte-component generate/steer is aborted: it tears down the matching session (or removes an orphaned [data-impeccable-variants] container). That teardown is wrapped in try/catch; if the DOM work throws — typically because the page's own framework already removed or remounted the nodes — the error is logged as 'abort cleanup failed:' and the remaining cleanup (observers, scroll lock, overlay, bar) still executes.

Source

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

    if (state !== 'CYCLING') setLiveState('GENERATING');
    injectSvelteComponentsFromManifest(manifestPath, sessionId);
  }

  // Tear down a component preview that could not mount, WITHOUT touching
  // session identity. The old version cleared localStorage, nulled
  // currentSessionId, and reset to PICKING, which orphaned a session the server
  // still had in its journal and made every recovery path unreachable. The DOM
  // teardown and observer cleanup are still right; the state wipe never was.
  function abortSvelteComponentInjection(sessionId, details) {
    try {
      if (svelteComponentSession?.sessionId === sessionId) {
        teardownSvelteComponentSession(true);
      } else {
        const orphan = document.querySelector('[data-impeccable-variants="' + sessionId + '"]');
        if (orphan) orphan.remove();
      }
    } catch (err) {
      console.warn('[impeccable] Svelte component abort cleanup failed:', err);
    }
    hideShaderOverlay();
    if (pendingSvelteComponentRetryObserver) { pendingSvelteComponentRetryObserver.disconnect(); pendingSvelteComponentRetryObserver = null; }
    if (pendingVariantAnchorRetryObserver) { pendingVariantAnchorRetryObserver.disconnect(); pendingVariantAnchorRetryObserver = null; }
    // The generate submit armed a scroll lock and a variant observer; a page
    // the user cannot scroll, watched by a stale observer, is exactly the
    // wrong place to show a card asking them to act.
    stopScrollLock();
    if (variantObserver) { variantObserver.disconnect(); variantObserver = null; }
    removeVariantStateStylesheet();
    hideBar(true);
    // currentSessionId, the saved session, and the file metadata all survive on
    // purpose: Retry, a republish from the agent, and a page reload all need
    // them. saveSession keeps the localStorage cache in step with the server.
    saveSession();
    if (details) showMountErrorCard(sessionId, details);
    else if (!mountErrorState) {
      showMountErrorCard(sessionId, { message: 'Variants could not be mounted. Retry, or ask the agent to republish.' });

View on GitHub (pinned to f88b2837a7)

Solutions

  1. Usually benign — verify no variant remnants, overlay, or scroll lock remain; reload the page if any do
  2. Guard teardown paths with element.isConnected checks before acting
  3. Debounce/dedupe abort triggers so cleanup runs once

Example fix

// before
const orphan = document.querySelector('[data-impeccable-variants="' + sessionId + '"]');
if (orphan) orphan.remove();
// after
const orphan = document.querySelector('[data-impeccable-variants="' + sessionId + '"]');
if (orphan?.isConnected) orphan.remove();
Defensive patterns

Strategy: fallback

Validate before calling

// Only tear down DOM that is still in the document
const orphan = document.querySelector(`[data-impeccable-variants="${sessionId}"]`);
if (orphan && !orphan.isConnected) return; // nothing live to clean

Try / catch

try { teardownSvelteComponentSession(true); } catch (err) { console.warn('abort cleanup failed', err); } // always continue with observer/scroll-lock cleanup

Prevention

When it happens

Trigger: The inspected app rerenders/remounts the variant region between abort decision and teardown; abort fires twice so the second pass finds already-detached nodes; teardownSvelteComponentSession walks a stale snapshot of removed elements.

Common situations: SPA hot-reload or hydration racing the abort; user navigating the app while aborting a generation; double-click on an abort control.

Related errors


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