Skip to content

fix: correctly calculate @const blockers#18032

Closed
dummdidumm wants to merge 6 commits into
mainfrom
const-await-blockers-fix
Closed

fix: correctly calculate @const blockers#18032
dummdidumm wants to merge 6 commits into
mainfrom
const-await-blockers-fix

Conversation

@dummdidumm

Copy link
Copy Markdown
Member

Fixes #18024

We need to calculate them in the analysis phase so they are all done after the transform phase. Else something like in the bug can happen where blockers are accessed before being finished calculating.

@changeset-bot

changeset-bot Bot commented Mar 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f7c97f6

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

@github-actions

Copy link
Copy Markdown
Contributor

Playground

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

@dummdidumm dummdidumm marked this pull request as draft March 30, 2026 20:44

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Suggestion:

Analysis phase Fragment visitor inherits async_consts from parent state causing blocker indices to be calculated incorrectly for nested scopes

Fix on Vercel

@dummdidumm dummdidumm marked this pull request as ready for review March 31, 2026 10:52
@svelte-docs-bot

Copy link
Copy Markdown

@dummdidumm

Copy link
Copy Markdown
Member Author

closing this for now - wanted to refactor this for better clarity but ConstTags live right at the intersection of the slot madness and the new async stuff as well as some Svelte boundary decisions we want to revert later and it's ... a lot. Better to do a focused fix which isn't as nice but easier to write/review. We can do a refactoring along these lines once all the legacy stuff is gone.

@dummdidumm dummdidumm closed this Mar 31, 2026
Rich-Harris added a commit that referenced this pull request Apr 9, 2026
Move the calculation of blockers into the analysis phase and then only
push the right thunks in the transform phase - similar to how we already
do it with top level `$.run`

Fixes #18024

The solution is a tiny bit brittle (not much more than the top level one
we already have) and I tried to make it a bit more robust but ended up
in a rabbit hole in #18032 - we can revisit that solution once all the
old stuff is gone. Until then this is the most pragmatic/non-invasive
change.

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
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.

Async Svelte crash in certain situations when destructuring awaited derived value in a @const

1 participant