Skip to content

fix: ensure mark_reactions occurs for dirty signals #12930

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

Closed
wants to merge 13 commits into from
Closed

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Aug 20, 2024

There was a bug in #12921. I've revised the logic and added a comment for it, we should only apply new heuristic for when we are setting the status to MAYBE_DIRTY.

Funnily the failing case is captured in the $state.link PR.

Copy link

changeset-bot bot commented Aug 20, 2024

🦋 Changeset detected

Latest commit: e352ecc

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

@trueadm trueadm marked this pull request as ready for review August 20, 2024 16:53
@@ -197,6 +197,9 @@ function mark_reactions(signal, status) {
// Skip any effects that are already dirty
if ((flags & DIRTY) !== 0) continue;

// We can skip this reaction if it's MAYBE_DIRTY and either UNOWNED or if we're setting the status to MAYBE_DIRTY
if ((flags & (CLEAN | UNOWNED)) === 0 && status === MAYBE_DIRTY) continue;
Copy link
Member

Choose a reason for hiding this comment

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

with this change (which I still find quite hard to parse if I'm honest!) the if on line 215 appears to be unnecessary:

if ((flags & (CLEAN | UNOWNED)) !== 0) {

Copy link
Member

Choose a reason for hiding this comment

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

Other conditions that behave equivalently, as far as the tests are concerned:

Suggested change
if ((flags & (CLEAN | UNOWNED)) === 0 && status === MAYBE_DIRTY) continue;
if ((flags & CLEAN) === 0 && status === MAYBE_DIRTY) continue;
Suggested change
if ((flags & (CLEAN | UNOWNED)) === 0 && status === MAYBE_DIRTY) continue;
if ((flags & status) !== 0) continue;

It's just really hard to tease apart the various elements here and understand when we mark and when we don't, and why.

@dummdidumm
Copy link
Member

dummdidumm commented Sep 10, 2024

@trueadm what's the status on this here? There was some concerns about readability, but given that it seems to fix #13174 (in which case we should also add a test to this PR) I'd like to get this in soon

@trueadm
Copy link
Contributor Author

trueadm commented Sep 10, 2024

@dummdidumm I don't see how this PR can fix that issue? I'll look into it tho

@dummdidumm
Copy link
Member

Mhm I think I was mistaken - one of the reproductions in that issue did work in the REPL of this PR, but I can't reproduce that anymore, it now fails in this one, too.

@Rich-Harris
Copy link
Member

Is this PR still live? As mentioned the logic is somewhat unclear, and the changeset and the code don't seem to correspond to each other

@trueadm
Copy link
Contributor Author

trueadm commented Sep 16, 2024

It was a perf opportunity. I’ve had bigger fish on my radar though so feel free to take over or close

@trueadm trueadm deleted the mark_bug branch November 6, 2024 15:02
@trueadm trueadm restored the mark_bug branch November 6, 2024 15:02
@trueadm trueadm deleted the mark_bug branch November 6, 2024 15:02
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.

3 participants