Skip to content
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

fix: ensure legacy run utility does not cause cycles #13643

Merged
merged 7 commits into from
Oct 17, 2024
Merged

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Oct 17, 2024

Fixes #13635. Not sure why the run function didn't already do this given it's surely meant to emulate Svelte 4 behaviour and not have cycles. @dummdidumm does this make sense?

Copy link

changeset-bot bot commented Oct 17, 2024

🦋 Changeset detected

Latest commit: e2530ca

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
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of run was to emulate Svelte 5 as closely as possible, which may also include reruns. But I agree that it's a bad look to automigrate code that then isn't working.

var effect = /** @type {import('#client').Effect} */ (active_effect);
// If the effect is immediately made dirty again, mark it as maybe dirty to emulate legacy behaviour
if ((effect.f & DIRTY) !== 0) {
set_signal_status(effect, MAYBE_DIRTY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool to warn in dev mode so people don't migrate towards effect and only then run into an infinite loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should the warning say here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a warning but unsure of the exact messaging. Maybe @Rich-Harris has a clearer idea on the wording.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message seems fine but it would be cool to include details of where the statement is. see how we do it in e.g. binding_property_non_reactive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we know the name of the reactive signal? It could be a binding, or a local variable or even a proxy signal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry I got confused — morning brain — thought that this warning applied to $: rather than run in which case we can just pass the location information from the compiler to the runtime. But yeah that doesn't make sense in this context

@trueadm trueadm merged commit 139114b into main Oct 17, 2024
9 checks passed
@trueadm trueadm deleted the legacy-run-fix branch October 17, 2024 13:05
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.

Migration of certain reactive blocks results in infinite loop
3 participants