{"record":{"id":"fcff4ea0b7257b9f","repo":"sveltejs/svelte","slug":"effect-pending-outside-reaction","errorCode":"effect_pending_outside_reaction","errorMessage":"effect_pending_outside_reaction\n`$effect.pending()` can only be called inside an effect or derived\nhttps://svelte.dev/e/effect_pending_outside_reaction","messagePattern":"effect_pending_outside_reaction\n`\\$effect\\.pending\\(\\)` can only be called inside an effect or derived\nhttps://svelte\\.dev/e/effect_pending_outside_reaction","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/svelte/src/internal/client/errors.js","lineNumber":231,"sourceCode":"\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/effect_orphan`);\n\t}\n}\n\n/**\n * `$effect.pending()` can only be called inside an effect or derived\n * @returns {never}\n */\nexport function effect_pending_outside_reaction() {\n\tif (DEV) {\n\t\tconst error = new Error(`effect_pending_outside_reaction\\n\\`$effect.pending()\\` can only be called inside an effect or derived\\nhttps://svelte.dev/e/effect_pending_outside_reaction`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/effect_pending_outside_reaction`);\n\t}\n}\n\n/**\n * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state\n * @returns {never}\n */\nexport function effect_update_depth_exceeded() {\n\tif (DEV) {\n\t\tconst error = new Error(`effect_update_depth_exceeded\\nMaximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state\\nhttps://svelte.dev/e/effect_update_depth_exceeded`);\n\n\t\terror.name = 'Svelte error';\n\n\t\tthrow error;\n\t} else {\n\t\tthrow new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);\n\t}\n}","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/sveltejs/svelte/blob/20b341f10048cf1016a2028ac7eee5595cfef6a5/packages/svelte/src/internal/client/errors.js#L213-L249","documentation":"Thrown by the pending() function in dom/blocks/boundary.js:548 when $effect.pending() is called and active_effect is null. $effect.pending() reports how many effects are outstanding within the nearest error boundary, so it can only meaningfully run while inside an effect or derived that belongs to a boundary.","triggerScenarios":"Calling $effect.pending() in module scope, in a plain event handler outside any component, or in a non-reactive callback. The guard at boundary.js:546-549 fires because active_effect===null.","commonSituations":"Reading $effect.pending() in a utility function invoked outside a component; using it in a plain .js file; calling it after the component unmounted; polling logic moved out of a component.","solutions":["Only call $effect.pending() from inside a $effect, $derived, or component template expression.","If you need a global 'are effects pending' indicator, expose it from a component via a prop or store rather than calling the rune externally.","Wrap the call site so it runs within component initialisation."],"exampleFix":"// before\nexport function logPending() {\n  console.log($effect.pending()); // no active effect\n}\n\n// after\n<script>\n  $effect(() => {\n    console.log($effect.pending()); // inside an effect\n  });\n</script>","handlingStrategy":"validation","validationCode":"// $effect.pending() requires an active effect. Guard by only calling it inside one.\n// If exposing a pending count, do so from inside an effect:\n// <script>\n//   let pendingCount = $state(0);\n//   $effect(() => { pendingCount = $effect.pending(); });\n// </script>","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call $effect.pending() from within a $effect, $derived, or template expression.","Do not call it from plain utility functions imported into non-component code.","Expose pending state through a component-owned reactive variable rather than calling the rune externally."],"tags":["svelte","runes","effects","boundary","reactivity"],"backgroundTag":null,"analyzedSha":"20b341f10048cf1016a2028ac7eee5595cfef6a5","analyzedAt":"2026-08-12T23:37:30.399Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}