-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: flush effects scheduled during boundary's pending phase #16738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: e36137d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a test for $effect
or is the attachment test sufficient?
One question is whether or not |
I agree. I'm not immediately sure how to make it behave that way; when the user effects are scheduled on So we either need to avoid pushing effects (and pre/render effects? though I guess those aren't scheduled on creation so we probably can't, which is probably fine) to the flush array during traversal, if they're inside a pending boundary (but not block/async effects, obviously), or otherwise exclude them from the flush. But I'm not totally sure how best to make that happen. I think the best move is to merge this to solve the immediate bug, then I'll open a PR with this failing test so that we don't lose it: --- a/packages/svelte/tests/runtime-runes/samples/async-effect-after-await/Child.svelte
+++ b/packages/svelte/tests/runtime-runes/samples/async-effect-after-await/Child.svelte
@@ -1,7 +1,11 @@
<script>
+ $effect(() => {
+ console.log('before');
+ });
+
await 1;
$effect(() => {
- console.log('hello');
+ console.log('after');
});
</script>
diff --git a/packages/svelte/tests/runtime-runes/samples/async-effect-after-await/_config.js b/packages/svelte/tests/runtime-runes/samples/async-effect-after-await/_config.js
index 81548a25e..0908b6a9f 100644
--- a/packages/svelte/tests/runtime-runes/samples/async-effect-after-await/_config.js
+++ b/packages/svelte/tests/runtime-runes/samples/async-effect-after-await/_config.js
@@ -3,7 +3,8 @@ import { test } from '../../test';
export default test({
async test({ assert, logs }) {
+ assert.deepEqual(logs, []);
await tick();
- assert.deepEqual(logs, ['hello']);
+ assert.deepEqual(logs, ['before', 'after']);
}
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed this also fixes #16582
Alternative to #16721, partial alternative to #16709. Closes #16691, closes #16627, closes #16582 and #16651 as well.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint