Skip to content

Commit e0e48b3

Browse files
committed
WIP
1 parent e49f81f commit e0e48b3

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/svelte/src/internal/client/reactivity/effects.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { get_next_sibling } from '../dom/operations.js';
4141
import { async_derived, derived } from './deriveds.js';
4242
import { capture } from '../dom/blocks/boundary.js';
4343
import { component_context, dev_current_component_function } from '../context.js';
44-
import { active_fork } from './forks.js';
44+
import { active_fork, Fork } from './forks.js';
4545

4646
/**
4747
* @param {'$effect' | '$effect.pre' | '$inspect'} rune
@@ -234,6 +234,7 @@ export function inspect_effect(fn) {
234234
* @returns {() => void}
235235
*/
236236
export function effect_root(fn) {
237+
Fork.ensure();
237238
const effect = create_effect(ROOT_EFFECT, fn, true);
238239

239240
return () => {
@@ -247,6 +248,7 @@ export function effect_root(fn) {
247248
* @returns {(options?: { outro?: boolean }) => Promise<void>}
248249
*/
249250
export function component_root(fn) {
251+
Fork.ensure();
250252
const effect = create_effect(ROOT_EFFECT, fn, true);
251253

252254
return (options = {}) => {

packages/svelte/src/internal/client/render.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
206206
// @ts-expect-error will be defined because the render effect runs synchronously
207207
var component = undefined;
208208

209-
Fork.ensure();
210-
211209
var unmount = component_root(() => {
212210
var anchor_node = anchor ?? target.appendChild(create_text());
213211

packages/svelte/src/internal/client/runtime.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,11 @@ function infinite_loop_guard() {
684684
function flush_queued_root_effects() {
685685
var was_updating_effect = is_updating_effect;
686686

687+
// TODO it should be impossible to get here without an active fork
688+
if (!active_fork && queued_root_effects.length > 0) {
689+
console.trace('here');
690+
}
691+
687692
try {
688693
var flush_count = 0;
689694
is_updating_effect = true;
@@ -901,6 +906,8 @@ function process_effects(root, async_effects, render_effects, effects) {
901906
export function flushSync(fn) {
902907
var result;
903908

909+
Fork.ensure();
910+
904911
if (fn) {
905912
is_flushing = true;
906913
flush_queued_root_effects();

0 commit comments

Comments
 (0)