{"record":{"id":"27d066f592b94cbf","repo":"sveltejs/svelte","slug":"invariant-violation","errorCode":"invariant_violation","errorMessage":"invariant_violation\nAn invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: \"${message}\"\nhttps://svelte.dev/e/invariant_violation","messagePattern":"invariant_violation\nAn invariant violation occurred, meaning Svelte's internal assumptions were flawed\\. This is a bug in Svelte, not your app — please open an issue at https://github\\.com/sveltejs/svelte, citing the following message: \"(.+?)\"\nhttps://svelte\\.dev/e/invariant_violation","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/internal/shared/errors.js","lineNumber":67,"sourceCode":"\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/invalid_snippet_arguments`);\n\t}\n}\n\n/**\n * An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: \"%message%\"\n * @param {string} message\n * @returns {never}\n */\nexport function invariant_violation(message) {\n\tif (DEV) {\n\t\tconst error = new Error(`invariant_violation\\nAn invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app — please open an issue at https://github.com/sveltejs/svelte, citing the following message: \"${message}\"\\nhttps://svelte.dev/e/invariant_violation`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/invariant_violation`);\n\t}\n}\n\n/**\n * `%name%(...)` can only be used during component initialisation\n * @param {string} name\n * @returns {never}\n */\nexport function lifecycle_outside_component(name) {\n\tif (DEV) {\n\t\tconst error = new Error(`lifecycle_outside_component\\n\\`${name}(...)\\` can only be used during component initialisation\\nhttps://svelte.dev/e/lifecycle_outside_component`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/lifecycle_outside_component`);\n\t}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/internal/shared/errors.js#L49-L85","documentation":"This is Svelte asserting its own internal invariants — conditions the framework considers always true. A violation is a bug in Svelte, not in your app. The error asks you to file an issue citing the `%message%`. It is thrown in both DEV (detailed) and production (URL-only) builds.","triggerScenarios":"Reaching an internal code path Svelte considered unreachable: a corrupted effect/state graph, an unexpected null internal handle, state used after teardown, or a double-activated effect. Often surfaces after unusual reactivity patterns, SSR/hydration mismatches, or rapid mount/unmount cycles.","commonSituations":"Hitting an edge case in Svelte's reactivity engine; SSR hydration mismatches; rapid concurrent mounting; upgrading to a Svelte version with a regression; combining runes with legacy stores in unsupported ways.","solutions":["Read the `%message%` and search https://github.com/sveltejs/svelte/issues for it.","Minimize the reproduction and file an issue with the Svelte version and a minimal repro.","Try the latest Svelte patch — it may already be fixed.","Work around it by simplifying reactivity (avoid mixing runes and legacy stores in one component)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n\t// risky Svelte render/mount/teardown path\n} catch (e) {\n\tif (String(e).includes('invariant_violation')) {\n\t\t// report to bug tracker; show fallback UI\n\t\thandleError(e);\n\t} else {\n\t\tthrow e;\n\t}\n}","preventionTips":["Pin a stable, tested Svelte version.","Avoid mixing runes ($state/$derived) with legacy stores in one component.","Ensure SSR and client render identical markup to avoid hydration mismatches.","Report violations with a minimal repro to sveltejs/svelte."],"tags":["internal","bug","invariant","svelte"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}