diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index 87e0d388dd..28a123b40c 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -107,17 +107,16 @@ export class Boundary { if (hydrating && pending) { this.#pending_effect = branch(() => pending(this.#anchor)); - // ...now what? we need to start rendering `boundary_fn` offscreen, - // and either insert the resulting fragment (if nothing suspends) - // or keep the pending effect alive until it unsuspends. - // not exactly sure how to do that. - // future work: when we have some form of async SSR, we will // need to use hydration boundary comments to report whether // the pending or main block was rendered for a given // boundary, and hydrate accordingly queueMicrotask(() => { - // destroy_effect(/** @type {Effect} */ (this.#pending_effect)); + if (this.#pending_count === 0) { + pause_effect(/** @type {Effect} */ (this.#pending_effect), () => { + this.#pending_effect = null; + }); + } this.#main_effect = this.#run(() => { return branch(() => this.#children(this.#anchor));