Skip to content

Commit 7c1408d

Browse files
committed
chore: run boundary async effects in the context of the current batch
1 parent 8691391 commit 7c1408d

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

.changeset/selfish-pets-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: run boundary async effects in the context of the current batch

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

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ export class Batch {
9797
*/
9898
#deferred = null;
9999

100-
/**
101-
* Async effects inside a newly-created `<svelte:boundary>`
102-
* — these do not prevent the batch from committing
103-
* @type {Effect[]}
104-
*/
105-
#boundary_async_effects = [];
106-
107100
/**
108101
* Template effects and `$effect.pre` effects, which run when
109102
* a batch is committed
@@ -158,8 +151,7 @@ export class Batch {
158151
this.#traverse_effect_tree(root);
159152
}
160153

161-
// if we didn't start any new async work, and no async work
162-
// is outstanding from a previous flush, commit
154+
// if there is no outstanding async work, commit
163155
if (this.#pending === 0) {
164156
// TODO we need this because we commit _then_ flush effects...
165157
// maybe there's a way we can reverse the order?
@@ -193,12 +185,6 @@ export class Batch {
193185
}
194186

195187
batch_values = null;
196-
197-
for (const effect of this.#boundary_async_effects) {
198-
update_effect(effect);
199-
}
200-
201-
this.#boundary_async_effects = [];
202188
}
203189

204190
/**
@@ -225,13 +211,9 @@ export class Batch {
225211
this.#effects.push(effect);
226212
} else if (async_mode_flag && (flags & RENDER_EFFECT) !== 0) {
227213
this.#render_effects.push(effect);
228-
} else if ((flags & CLEAN) === 0) {
229-
if ((flags & ASYNC) !== 0 && effect.b?.is_pending()) {
230-
this.#boundary_async_effects.push(effect);
231-
} else if (is_dirty(effect)) {
232-
if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
233-
update_effect(effect);
234-
}
214+
} else if (is_dirty(effect)) {
215+
if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
216+
update_effect(effect);
235217
}
236218

237219
var child = effect.first;

0 commit comments

Comments
 (0)