Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: more informative error when effects run in an infinite loop#16405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Ocean-OS merged 8 commits intomainfrombetter-self-invalidation-logging
Jul 16, 2025

Conversation

Rich-Harris
Copy link
Member

Supersedes#16247,closes#16092.

Today, if you have an effect that runs in an infinite loop, you get this somewhat unhelpful log:

image

Expanding the array usually reveals 10 copies of the same compiled function:

image

While youcan click through to the[[FunctionLocation]]...

image

...even that doesn't necessarily tell you where the offending state change occurred.

We can do better. In this PR, we track the site of updates to state that occur inside an effect, then if wedo encounter an infinite loop we can pinpoint those sites:

image

This works for things like array mutations, and even works for effects that ping-pong (as opposed to the probably-more-common case in which an effect invalidates itself):

$effect(()=>{a=b+1;});$effect(()=>{b=a+1;});

Better yet, this is actuallysimpler than what we currently have — the implementation ofinfinite_loop_guard can be much leaner, andlog_effect_stack anddev_effect_stack are no more.

This PR also adds an explanation of the error. For things like this I prefer progressive disclosure (i.e. link to the docs when it becomes relevant) rather than adding stuff that you have to read upfront, so I view this as an alternative to#16247.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC:https://github.com/sveltejs/rfcs
  • Prefix your PR title withfeat:,fix:,chore:, ordocs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code withinpackages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests withpnpm test and lint the project withpnpm lint

janosh reacted with thumbs up emoji
@changeset-botchangeset-bot
Copy link

changeset-botbot commentedJul 16, 2025
edited
Loading

🦋 Changeset detected

Latest commit:90ff2dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
sveltePatch

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

@github-actionsGitHub Actions
Copy link
Contributor

Playground

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

@Ocean-OSOcean-OS merged commita67b586 intomainJul 16, 2025
15 checks passed
@Ocean-OSOcean-OS deleted the better-self-invalidation-logging branchJuly 16, 2025 23:24
@github-actionsgithub-actionsbot mentioned this pull requestJul 16, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@Ocean-OSOcean-OSOcean-OS approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Testing of rune effects is broken
2 participants
@Rich-Harris@Ocean-OS

[8]ページ先頭

©2009-2025 Movatter.jp