diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index 6525b3e5fb..2c7136ef10 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -47,6 +47,7 @@ import { loop } from '../../loop.js'; export class Boundary { suspended = false; + inert = false; /** @type {Boundary | null} */ parent; @@ -106,13 +107,7 @@ export class Boundary { this.parent = /** @type {Effect} */ (active_effect).b; this.#effect = block(() => { - var boundary_effect = /** @type {Effect} */ (active_effect); - boundary_effect.b = this; - - // @ts-ignore We re-use the effect's fn property to avoid allocation of an additional field - boundary_effect.fn = (/** @type {unknown} */ input) => { - this.error(input); - }; + /** @type {Effect} */ (active_effect).b = this; if (hydrating) { hydrate_next(); diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index acd863c566..d872503ab6 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -252,22 +252,19 @@ export function check_dirtiness(reaction) { * @param {Effect} effect */ function propagate_error(error, effect) { - /** @type {Effect | null} */ - var current = effect; + var boundary = effect.b; - while (current !== null) { - if ((current.f & BOUNDARY_EFFECT) !== 0) { + while (boundary !== null) { + if (!boundary.inert) { try { - // @ts-expect-error - current.fn(error); + boundary.error(error); return; } catch { - // Remove boundary flag from effect - current.f ^= BOUNDARY_EFFECT; + boundary.inert = true; } } - current = current.parent; + boundary = boundary.parent; } is_throwing_error = false; @@ -278,10 +275,7 @@ function propagate_error(error, effect) { * @param {Effect} effect */ function should_rethrow_error(effect) { - return ( - (effect.f & DESTROYED) === 0 && - (effect.parent === null || (effect.parent.f & BOUNDARY_EFFECT) === 0) - ); + return (effect.f & DESTROYED) === 0 && (effect.parent === null || !effect.b || effect.b.inert); } export function reset_is_throwing_error() {