fix: ensure infinite effect loops are cleared after flushing (#17601)

* failing effect-loop-infinite test

* fix
pull/17633/head
Rich Harris 5 days ago committed by GitHub
parent eb63a6bbba
commit 4f41e816ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure infinite effect loops are cleared after flushing

@ -647,8 +647,9 @@ function flush_effects() {
}
}
} finally {
is_flushing = false;
queued_root_effects = [];
is_flushing = false;
last_scheduled_effect = null;
if (DEV) {

@ -521,6 +521,8 @@ async function run_test_variant(
errors,
hydrate: hydrate_fn
});
flushSync();
}
if (config.runtime_error && !unhandled_rejection) {

@ -11,11 +11,12 @@ export default test({
test({ assert, errors }) {
const [button] = document.querySelectorAll('button');
try {
assert.throws(() => {
flushSync(() => button.click());
} catch (e) {
assert.equal(errors.length, 1); // for whatever reason we can't get the name which should be 'updated at'
assert.ok(/** @type {Error} */ (e).message.startsWith('effect_update_depth_exceeded'));
}
}, /effect_update_depth_exceeded/);
assert.equal(errors.length, 1);
assert.doesNotThrow(flushSync);
}
});

Loading…
Cancel
Save