Skip to content

fix: avoid false-positive batch invariant error#18246

Merged
Rich-Harris merged 1 commit into
mainfrom
invariant-false-positive
May 20, 2026
Merged

fix: avoid false-positive batch invariant error#18246
Rich-Harris merged 1 commit into
mainfrom
invariant-false-positive

Conversation

@dummdidumm

Copy link
Copy Markdown
Member

Thanks to #17940 (comment) I was finally able to isolate and reproduce a false-positive invariant error. I had a hunch this could happen and this shows it. Essentially, you can end up in situations where two batches are scheduled to run in the same microtask queue flush, and if the first rebases the second the invariant will throw, which is wrong. We can avoid this by checking if a decrement is queued.

Thanks to #17940 (comment) I was finally able to isolate and reproduce a false-positive invariant error. I had a hunch this could happen and this shows it. Essentially, you can end up in situations where two batches are scheduled to run in the same microtask queue flush, and if the first rebases the second the invariant will throw, which is wrong. We can avoid this by checking if a decrement is queued.
@changeset-bot

changeset-bot Bot commented May 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 979d798

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@18246

@Rich-Harris Rich-Harris merged commit d654db8 into main May 20, 2026
21 checks passed
@Rich-Harris Rich-Harris deleted the invariant-false-positive branch May 20, 2026 01:04
@github-actions github-actions Bot mentioned this pull request May 19, 2026
dummdidumm pushed a commit that referenced this pull request May 20, 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.9

### Patch Changes

- fix: don't unset batch when calling `{#await ...}` promise
([#18243](#18243))

- fix: promise-ify `{#await await ...}` expressions on the server and
correctly hydrate them on the client
([#18243](#18243))

- fix: deduplicate dependencies that are added outside the init/update
cycle ([#18243](#18243))

- fix: avoid false-positive batch invariant error
([#18246](#18246))

- fix: inline primitive constants in attribute values during SSR
([#18232](#18232))

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