Skip to content

fix: ignore false-positive errors of $inspect dependencies#18106

Merged
Rich-Harris merged 7 commits into
mainfrom
eager-effects-derived-fix
Apr 29, 2026
Merged

fix: ignore false-positive errors of $inspect dependencies#18106
Rich-Harris merged 7 commits into
mainfrom
eager-effects-derived-fix

Conversation

@dummdidumm

Copy link
Copy Markdown
Member

We had logic in place to ignore errors of $inspect effects that are about to destroy, but we didn't take into account that we can get these transient errors while checking for is_dirty in preparation for running the effect, too. Now effects are marked as dirty in case an error occurs while evaluating their dependencies, which guarantees we will see the error again but we can then handle it properly.

Fixes #15741

We had logic in place to ignore errors of `$inspect` effects that are about to destroy, but we didn't take into account that we can get these transient errors while checking for `is_dirty` in preparation for running the effect, too. Now effects are marked as dirty in case an error occurs while evaluating their dependencies, which guarantees we will see the error again but we can then handle it properly.

Fixes #15741
@changeset-bot

changeset-bot Bot commented Apr 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0e35bd8

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

@afurm

afurm commented Apr 13, 2026

Copy link
Copy Markdown

The try/catch with dirty = true catches errors from is_dirty (which evaluates derived dependencies) and defers to the effect's own error handler by forcing a re-run. This is safe when the error is genuinely transient (parent destroying child). But if the error is non-transient — a real bug in a derived signal — the effect will re-run indefinitely since is_dirty will keep throwing. Is there a mechanism to break that cycle, or is that case considered impossible for the specific is_dirty errors that can occur during dirty-checking?

dummdidumm added a commit that referenced this pull request Apr 13, 2026
While working on #18106 I noticed that we're not adding eager effects inside `mark_reactions` when `DEV` is `false`. As a result production build could have `$state.eager` or `$state.pending` not working correctly.

No test because I can't get Vitest to not run with `DEV` being `true`.
Rich-Harris pushed a commit that referenced this pull request Apr 29, 2026
While working on #18106 I noticed that we're not adding eager effects
inside `mark_reactions` when `DEV` is `false`. As a result production
build could have `$state.eager` or `$state.pending` not working
correctly.

~No test because I can't get Vitest to not run with `DEV` being `true`.~
added a test
@Rich-Harris

Copy link
Copy Markdown
Member

@afurm there's no loop here that I can see, calling update_effect won't cause flush_eager_effects to re-run

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

actually, rescinding my approval until I can better understand something — I found a case that's buggy in this PR. It's buggy on main too but differently:

  • main — the error is logged twice
  • this PR — the error is logged once when it applies (when a is odd), but is then logged again when a is even, incorrectly

@Rich-Harris

Copy link
Copy Markdown
Member

pushed a fix, albeit without a test because I'm not quite sure how to write one for it

@Rich-Harris Rich-Harris merged commit 572444a into main Apr 29, 2026
20 checks passed
@Rich-Harris Rich-Harris deleted the eager-effects-derived-fix branch April 29, 2026 23:20
@github-actions github-actions Bot mentioned this pull request Apr 29, 2026
Rich-Harris pushed a commit that referenced this pull request May 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.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>
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.

$inspect in child component wrapped in {#if} block throws error when if block becomes falsy

3 participants