Skip to content

fix: keep flushing new eager effects#18102

Merged
dummdidumm merged 3 commits into
mainfrom
eager-effects-array-fix
Apr 13, 2026
Merged

fix: keep flushing new eager effects#18102
dummdidumm merged 3 commits into
mainfrom
eager-effects-array-fix

Conversation

@dummdidumm

Copy link
Copy Markdown
Member

The previous code "swallowed" new additions to the array of eager effects that happened while flushing since eager_flush did not clear the array before running, only afterwards. Now it clears the beforehand, causing newly added eager effects to run, too.

An example where this can happen is $state.eager and $effect.pending in combination: first $state.eager is flushed, then due to flushSync the queue_micro_task inside boundary.js that flushes $effect.pending is triggered synchronously, adding new entries to the eager_versions array. If they're only cleared at the end of eager_flush, new entries are swallowed.

Related to #18095 (but not fixing it yet)

The previous code "swallowed" new additions to the array of eager effects that happened while flushing since `eager_flush` did not clear the array before running, only afterwards. Now it clears the beforehand, causing newly added eager effects to run, too.

An example where this can happen is `$state.eager` and `$effect.pending` in combination: first `$state.eager` is flushed, then due to `flushSync` the `queue_micro_task` inside `boundary.js` that flushes `$effect.pending` is triggered synchronously, adding new entries to the `eager_versions` array. If they're only cleared at the end of `eager_flush`, new entries are swallowed.

Related to #18095 (but not fixing it yet)
@changeset-bot

changeset-bot Bot commented Apr 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ec43e4b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

@svelte-docs-bot

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@18102

Comment thread packages/svelte/src/internal/client/reactivity/batch.js Outdated

@Rich-Harris Rich-Harris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs changeset but otherwise LGTM

@dummdidumm dummdidumm merged commit 273f1a8 into main Apr 13, 2026
14 of 15 checks passed
@dummdidumm dummdidumm deleted the eager-effects-array-fix branch April 13, 2026 09:33
@github-actions github-actions Bot mentioned this pull request Apr 13, 2026
dummdidumm pushed a commit that referenced this pull request Apr 14, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## svelte@5.55.4

### Patch Changes

- fix: never mark a child effect root as inert
([#18111](#18111))

- fix: reset context after waiting on blockers of `@const` expressions
([#18100](#18100))

- fix: keep flushing new eager effects
([#18102](#18102))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants