Skip to content

fix: avoid recursion error when tagging circular references #16622

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 14, 2025
Merged

Conversation

Ocean-OS
Copy link
Member

Closes #16620

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 with feat:, fix:, chore:, or docs:.
  • 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 within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Aug 14, 2025

🦋 Changeset detected

Latest commit: e738d6a

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

Copy link
Contributor

Playground

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

@7nik
Copy link
Contributor

7nik commented Aug 14, 2025

Won't it be cheaper to set a flag that update_path runs to it shouldn't run again due to circular deps?

@Ocean-OS
Copy link
Member Author

what do you mean?

@7nik
Copy link
Contributor

7nik commented Aug 14, 2025

let updating = false;
function update_path(new_path) {
  if (updating) return; // met a circular dependency
  updating = true;
  // fn body
  updating = false;
}

@Ocean-OS
Copy link
Member Author

thanks!

@7nik
Copy link
Contributor

7nik commented Aug 14, 2025

But, unlike the previous solution, it causes weird tags 🤔
image

@paoloricciuti
Copy link
Member

But, unlike the previous solution, it causes weird tags 🤔 image

When i was exploring this i think it's because when we set we create an unlabeled proxy (so I think it's semi, unrelated to this)

@Ocean-OS
Copy link
Member Author

when you say set, do you mean the set proxy handler or the set function?

@7nik
Copy link
Contributor

7nik commented Aug 14, 2025

Nice. I guess we still need a test, right?

@Ocean-OS Ocean-OS merged commit a543559 into main Aug 14, 2025
16 checks passed
@Ocean-OS Ocean-OS deleted the gh-16620 branch August 14, 2025 20:36
@github-actions github-actions bot mentioned this pull request Aug 14, 2025
@paoloricciuti
Copy link
Member

when you say set, do you mean the set proxy handler or the set function?

Ugh sorry, I missed this but I think you found it right?

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.

Crash on circular reference assignment in $state with 5.34.0+
3 participants