fix: leave stale promises to wait for a later resolution, instead of rejecting#18180
Conversation
🦋 Changeset detectedLatest commit: 4f66366 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 |
|
|
Will investigate tomorrow but I'm not sure if this just shifts the buggy behavior away from stale reactions towards obsolete ones (i.e. that you can construct test cases which are similar to the ones with |
|
On a mechanical level I feel good about the fix, because the problem we had was one of asymmetry — it was possible to increment a batch but not (properly) decrement it. That was always trivial to fix by getting rid of the On a conceptual level I feel good about it too — when you use
When the abort signal aborts, nothing happens, so 'if a derived with |
|
Here's an example where you see out-of-sync values (1 + 0 = 0) which you don't see on main currently. Quick debugging let to Update: may have found a solution - defer the resolve of earlier batches until the current batch commits. That way there's no tearing, and the earlier batch still has time to resolve itself before that. Update: Did that in #18181 |
|
Gah, merging |
) builds on top of #18180 Tweaks the timing when we resolve earlier/outdated batches. Instead of doing that right away we only do it once the current batch is committed. That way - the old batch will not render right away in case this was the last pending value, while the current batch is still pending, causing tearing (because we partly render values of the current batch in the old batch already) - the old batch still has a chance to resolve itself in the meantime if the current batch is still pending in other areas --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>
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.6 ### Patch Changes - fix: leave stale promises to wait for a later resolution, instead of rejecting ([#18180](#18180)) - fix: keep dependencies of `$state.eager/pending` ([#18218](#18218)) - fix: reapply context after transforming error during SSR ([#18099](#18099)) - fix: don't rebase just-created batches ([#18117](#18117)) - chore: allow `null` for `pending` in typings ([#18201](#18201)) - fix: flush eager effects in production ([#18107](#18107)) - fix: rethrow error of failed iterable after calling `return()` ([#18169](#18169)) - fix: account for proxified instance when updating `bind:this` ([#18147](#18147)) - fix: ensure scheduled batch is flushed if not obsolete ([#18131](#18131)) - fix: resolve stale deriveds with latest value ([#18167](#18167)) - chore: remove unnecessary `increment_pending` calls ([#18183](#18183)) - fix: correctly compile component member expressions for SSR ([#18192](#18192)) - fix: reset `source.updated` stack traces after `flush` ([#18196](#18196)) - fix: replacing async 'blocking' strategy with 'merging' ([#18205](#18205)) - fix: allow `@debug` tags to reference awaited variables ([#18138](#18138)) - fix: re-run fallback props if dependencies update ([#18146](#18146)) - fix: abort running obsolete async branches ([#18118](#18118)) - fix: ignore comments when reading CSS values ([#18153](#18153)) - fix: wrap `Promise.all` in `save` during SSR ([#18178](#18178)) - fix: ignore false-positive errors of `$inspect` dependencies ([#18106](#18106)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This incorporates some of the fixes and insights from #18177, but gets rid of the
skiplogic.Instead, we differentiate between stale and obsolete promises. A promise is stale if it has been overtaken by a subsequent update, and was rejected with
STALE_REACTION:In this case, if we start typing
pot, and then finish typingpotato, the first promise will eventually resolve with the results for/search?q=potato, instead of the batch entering a weird limbo/zombie state.A promise is obsolete if it belongs to a now-destroyed effect, meaning that toggling
showdoesn't result in an accumulation of never-resolving batches:{#if show} {await neverResolves()} {/if}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 testand lint the project withpnpm lint