mirror of https://github.com/sveltejs/svelte
fix: prevent batch unlinking twice (#18303)
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.pull/18311/head
parent
0da9f9e2ab
commit
638ab370a5
Loading…
Reference in new issue