Skip to content

fix: only unlink batch if we're done with it#18298

Merged
dummdidumm merged 7 commits into
mainfrom
unlink-when-ready
May 27, 2026
Merged

fix: only unlink batch if we're done with it#18298
dummdidumm merged 7 commits into
mainfrom
unlink-when-ready

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

alternative to #18296 — no need to make batches relinkable if we only unlink them when we're fully done with them

@changeset-bot

changeset-bot Bot commented May 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9643532

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

@github-actions

Copy link
Copy Markdown
Contributor

Playground

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

@svelte-docs-bot

Copy link
Copy Markdown

@dummdidumm dummdidumm merged commit ec08dbc into main May 27, 2026
21 checks passed
@dummdidumm dummdidumm deleted the unlink-when-ready branch May 27, 2026 08:20
@github-actions github-actions Bot mentioned this pull request May 27, 2026
Rich-Harris pushed a commit that referenced this pull request May 27, 2026
Merged #18298 a bit too soon - there's still a situation which can
corrput the linked list: If we merge one batch into another, it will
unlink the batch immediately. But `discard` also calls it, running the
unlink logic again, which can corrupt the linked list.

Sketch:

1. Batch A is pending.
2. Batch B starts later, intersects A, resolves first, and merges into
A.
3. B is unlinked immediately, but `A.oncommit(() => B.discard())`
remains.
4. Independent batch C is created while A is still pending and is linked
after A.
5. A commits, calls `B.discard()`, and B's stale `#prev`/`#next` can set
`A.#next = null` / `last_batch = A`, disconnecting C.

Not able to produce a failing test from it but it's definitely a fix we
need to make.

Also moved `#link` into a constructor, because it is (and should be)
used only once.

Also made the action after an error `discard` instead of just `#unlink`
because this batch is done for and e.g. pending `settled` should
resolve, too.
Rich-Harris pushed a commit that referenced this pull request May 27, 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.10

### Patch Changes

- fix: unlink errored and otherwise finished batch
([#18264](#18264))

- perf: walk composedPath() directly in delegated event propagation
([#18268](#18268))

- fix: transfer effects when merging batches
([#18254](#18254))

- fix: allow `$derived(await ...)` in disconnected effect roots
([#18273](#18273))

- fix: remove temporary raw-text hydration markers
([#18269](#18269))

- fix: propagate async `@const` blockers through closure references so
template expressions like `{(() => host)()}` correctly wait for the
awaited value ([#18309](#18309))

- fix: properly unlink batches
([#18298](#18298))

- fix: settle discarded batch
([#18290](#18290))

- fix: declare `let:` directives before `{@const}` declarations on
slotted elements
([#18271](#18271))

- fix: resume outro-ed branches if they were kept around
([#18291](#18291))

- fix: avoid waterfall-warning when async resolves to same value
([#18297](#18297))

- fix: correctly coordinate component-level effects inside async blocks
([#18260](#18260))

- fix: make unnecessary commit work less likely
([#18263](#18263))

- chore: add tag name to `a11y_click_events_have_key_events` warning
([#18272](#18272))

- fix: catch rejected promises while merging/committing
([#18266](#18266))

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