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: run blocks eagerly during flush#16631

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
dummdidumm merged 11 commits intomainfromgh-16548-eager-block
Aug 17, 2025
Merged

Conversation

@Rich-Harris
Copy link
Member

Another stab at#16548. The idea is that if a block effect is dirtied by a state change in another effect, it jumps to the head of the queue rather than waiting for the next root-to-tip traversal. That way, if it ends up destroying its children, they get destroyed immediately, rather than running even though they'reabout to be destroyed (which can result in errors —#16072).

Because we're not causing extra traversals, this (as far as I've been able to determine) fully removes the performance overhead introduced by#16280, without regressing on correctness. It also fixes the false positive infinite loop detection.

The one part I really don't love is theold_values.clear() — it gets the tests passing (one fails without it) but feels wrong. I stole it from#16612 — maybe@dummdidumm can explain if/why/how it's okay.

It also seems weird that we need to schedule the block effects inaddition to running them eagerly, but if we don't then one test fails. Will investigate when my brain isn't running on fumes.

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

pitzzahh reacted with hooray emojitechniq, l0uisgrange, Prajwalg19, MarcosGGlleezz, pitzzahh, and AndreaMenci reacted with heart emoji
@changeset-bot
Copy link

🦋 Changeset detected

Latest commit:5d6b081

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

@github-actions
Copy link
Contributor

Playground

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

break;
if(eager_block_effects.length>0){
// TODO this feels incorrect! it gets the tests passing
old_values.clear();
Copy link
Member

Choose a reason for hiding this comment

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

This is the correct place since it's equivalent timing to before: previously you would bail the loop and start a new flush. That means you ended up at the end of theflush_effects loop where we also callclear(), and then did another flush.
I have some nagging doubts if the logic in general for this is sound but we can tackle that later.

if(eager_block_effects!==null){
eager_block_effects.push(/**@type {Effect} */(reaction));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

My guess for why this is necessary is that in the next batch that was scheduled due to this we need it for traversal of the graph.
That said ideally we could avoid or abort the next batch flush completely if we determine that it didn't schedule anything else. A possible optimization for some other time.

@Rich-HarrisRich-Harris marked this pull request as ready for reviewAugust 17, 2025 12:18
@dummdidummdummdidumm merged commit2b85d2a intomainAug 17, 2025
14 checks passed
@dummdidummdummdidumm deleted the gh-16548-eager-block branchAugust 17, 2025 12:31
@github-actionsgithub-actionsbot mentioned this pull requestAug 15, 2025
@Prajwalg19
Copy link

for methis problem still exists even after2b85d2a

dummdidumm added a commit that referenced this pull requestOct 21, 2025
Fixes#16850,fixes#16775,fixes#16795,fixes#16982#16631 introduced a bug that results in the effects within guards being evaluated before the guards themselves. This fix makes sure to iterate the block effects in the correct order (top down)---------Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

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

4 participants

@Rich-Harris@Prajwalg19@dummdidumm

[8]ページ先頭

©2009-2025 Movatter.jp