diff --git a/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js b/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js index c1c8170e30..46c13d1a6f 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js @@ -371,7 +371,7 @@ export function client_component(analysis, options) { const body = b.function_declaration( b.id('$$body'), [b.id('$$anchor'), b.id('$$props')], - component_block + b.block([...component_block.body, b.stmt(b.call('$.exit'))]) ); body.async = true; diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index c51d04b1b1..6b2e4e1ba1 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -297,6 +297,10 @@ export async function suspend(promise) { // @ts-ignore boundary?.fn(ASYNC_INCREMENT); + // prevent the active effect from outstaying its welcome + // TODO is a microtask too late? is this correct? + queue_post_micro_task(exit); + const value = await promise; return { diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index 75942c9b4c..c937f7fb9c 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -98,6 +98,13 @@ export function set_active_effect(effect) { active_effect = effect; } +// TODO remove this, once we're satisfied that we're not leaking context +setInterval(() => { + if (active_effect !== null || active_reaction !== null) { + debugger; + } +}); + /** * When sources are created within a derived, we record them so that we can safely allow * local mutations to these sources without the side-effect error being invoked unnecessarily.