pbakaus/impeccable · warning

[impeccable] Svelte component reset cleanup failed:

Error message

[impeccable] Svelte component reset cleanup failed:

What it means

resetSvelteComponentSession is the hard reset for a svelte-component session that is cycling with nothing to cycle to: it tears down the session or removes the orphaned variants container, disconnects all observers, releases the scroll lock, clears the error card, and wipes session state. The teardown step is individually try/caught; if it throws (detached/foreign-owned DOM), the error is logged as 'reset cleanup failed:' and the rest of the reset still completes, including clearing currentSessionId.

Source

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

    if (details) showMountErrorCard(sessionId, details);
    else if (!mountErrorState) {
      showMountErrorCard(sessionId, { message: 'Variants could not be mounted. Retry, or ask the agent to republish.' });
    }
  }

  // Hard reset for the one case that is not a mount failure: a cycling state
  // with nothing to cycle. There is no variant to retry and no URL to report,
  // so the session really is over.
  function resetSvelteComponentSession(sessionId, message) {
    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 reset cleanup failed:', err);
    }
    hideShaderOverlay();
    if (variantObserver) { variantObserver.disconnect(); variantObserver = null; }
    if (pendingSvelteComponentRetryObserver) { pendingSvelteComponentRetryObserver.disconnect(); pendingSvelteComponentRetryObserver = null; }
    if (pendingVariantAnchorRetryObserver) { pendingVariantAnchorRetryObserver.disconnect(); pendingVariantAnchorRetryObserver = null; }
    stopScrollLock();
    removeVariantStateStylesheet();
    clearMountErrorCard();
    clearSession();
    clearHandled();
    resetSessionFileMeta();
    currentSessionId = null;
    parameterGenerationState = 'idle';
    parameterReadyAnnouncedSession = null;
    expectedVariants = 0;
    arrivedVariants = 0;
    visibleVariant = 0;
    selectedElement = null;

View on GitHub (pinned to f88b2837a7)

Solutions

  1. Benign in most cases — confirm the variants container, observers, and scroll lock are gone; reload if residue persists
  2. Add isConnected guards before DOM teardown
  3. Trigger the reset once per session end, not on every unrelated state change

Example fix

// before
if (svelteComponentSession?.sessionId === sessionId) teardownSvelteComponentSession(true);
// after
if (svelteComponentSession?.sessionId === sessionId && document.contains(variantHostEl)) teardownSvelteComponentSession(true);
Defensive patterns

Strategy: fallback

Validate before calling

if (svelteComponentSession?.sessionId === sessionId && !document.contains(sessionHostEl)) {
  // host already removed by the app — skip DOM teardown, still clear state
}

Try / catch

try { teardownSvelteComponentSession(true); } catch (err) { console.warn('reset cleanup failed', err); } // proceed: observers, scroll lock, and session state must clear regardless

Prevention

When it happens

Trigger: The app framework removed the variants container before the reset ran; reset racing a remount; the container's parent replaced by framework code that invalidates the cached reference.

Common situations: Session reset landing after a page navigation or hydration pass; repeated resets in quick succession; third-party scripts mutating the same DOM region.

Related errors


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