{"record":{"id":"fc82b144362316aa","repo":"pbakaus/impeccable","slug":"impeccable-svelte-component-reset-cleanup-failed","errorCode":null,"errorMessage":"[impeccable] Svelte component reset cleanup failed:","messagePattern":"\\[impeccable\\] Svelte component reset cleanup failed:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"skill/scripts/live-browser.js","lineNumber":6193,"sourceCode":"    if (details) showMountErrorCard(sessionId, details);\n    else if (!mountErrorState) {\n      showMountErrorCard(sessionId, { message: 'Variants could not be mounted. Retry, or ask the agent to republish.' });\n    }\n  }\n\n  // Hard reset for the one case that is not a mount failure: a cycling state\n  // with nothing to cycle. There is no variant to retry and no URL to report,\n  // so the session really is over.\n  function resetSvelteComponentSession(sessionId, message) {\n    try {\n      if (svelteComponentSession?.sessionId === sessionId) {\n        teardownSvelteComponentSession(true);\n      } else {\n        const orphan = document.querySelector('[data-impeccable-variants=\"' + sessionId + '\"]');\n        if (orphan) orphan.remove();\n      }\n    } catch (err) {\n      console.warn('[impeccable] Svelte component reset cleanup failed:', err);\n    }\n    hideShaderOverlay();\n    if (variantObserver) { variantObserver.disconnect(); variantObserver = null; }\n    if (pendingSvelteComponentRetryObserver) { pendingSvelteComponentRetryObserver.disconnect(); pendingSvelteComponentRetryObserver = null; }\n    if (pendingVariantAnchorRetryObserver) { pendingVariantAnchorRetryObserver.disconnect(); pendingVariantAnchorRetryObserver = null; }\n    stopScrollLock();\n    removeVariantStateStylesheet();\n    clearMountErrorCard();\n    clearSession();\n    clearHandled();\n    resetSessionFileMeta();\n    currentSessionId = null;\n    parameterGenerationState = 'idle';\n    sessionOrigin = null;\n    editBadgeSuppressed = false;\n    parameterReadyAnnouncedSession = null;\n    expectedVariants = 0;\n    arrivedVariants = 0;","sourceCodeStart":6175,"sourceCodeEnd":6211,"githubUrl":"https://github.com/pbakaus/impeccable/blob/f2c7051853848826aac2f4646581d62a732155ad/skill/scripts/live-browser.js#L6175-L6211","documentation":"Same cleanup path as the abort variant, but fired when a Svelte component session is reset (e.g. after empty cycling state). The teardown/orphan removal threw; it is warned and the reset continues with overlay hiding, observer disconnects, and scroll-lock release.","triggerScenarios":"resetSvelteComponentSession invokes teardownSvelteComponentSession(true) or removes the orphan [data-impeccable-variants] node and it throws; caught at skill/scripts/live-browser.js:6170.","commonSituations":"Reset triggered by recoverEmptyCycling while the component session is half-torn-down; framework HMR swapped out the DOM node; session bookkeeping already cleared by an earlier abort.","solutions":["Reload the page to clear stale session state.","Re-run the generation; reset is recoverable and subsequent state is cleaned.","Check devtools for duplicated or already-removed [data-impeccable-variants] nodes.","If reproducible with a specific framework setup, file an issue with the fixture/stack."],"exampleFix":"// before\ntry { teardownSvelteComponentSession(true); } catch (err) { console.warn(...); }\n// after (idempotent teardown)\ntry { if (svelteComponentSession) teardownSvelteComponentSession(true); } catch (err) { console.warn(...); svelteComponentSession = null; }","handlingStrategy":"try-catch","validationCode":"function sessionTeardownable(session) {\n  return !!session && typeof session.sessionId === 'string' &&\n    !!document.querySelector('[data-impeccable-variants=\"' + session.sessionId + '\"]');\n}","typeGuard":null,"tryCatchPattern":"try {\n  teardownSvelteComponentSession(true);\n} catch (err) {\n  console.warn('[impeccable] Svelte component reset cleanup failed:', err);\n} finally {\n  hideShaderOverlay();\n  stopScrollLock();\n}","preventionTips":["Reset only sessions that still exist; check sessionId matches currentSessionId","Keep reset and abort cleanup paths sharing one idempotent teardown function","Clear observer references in finally blocks so state never leaks"],"tags":["svelte","cleanup","browser","dom"],"backgroundTag":"invalid-state-transition","analyzedSha":"f2c7051853848826aac2f4646581d62a732155ad","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}