-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: async hydration #16797
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: async hydration #16797
Conversation
🦋 Changeset detectedLatest commit: 994583c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
This turned out to be a bit of a rabbit hole — we're not currently handling I think that stuff is basically fixed though there's still some stuff I want to look at tomorrow:
Once all that's done, we can get to work on the coordinated updates stuff |
Okay, done — hydration works with async blocks, async attributes are now supported outside a |
packages/svelte/src/compiler/phases/3-transform/server/visitors/SvelteElement.js
Show resolved
Hide resolved
packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/component.js
Outdated
Show resolved
Hide resolved
packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js
Outdated
Show resolved
Hide resolved
packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/utils.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks great
We missed a crucial detail in #16784 — content after an async block isn't correctly hydrated, because the hydration state gets corrupted.
Conceptually the fix is very straightforward. We need to wrap each async block in hydration markers (
<!--[-->
and<!--]-->
), and when encountering an async block, stash thehydrate_node
, skip ahead to the<!--]-->
, hydrate the next thing, and then restorehydrate_node
when the async block is ready to proceed. I'd like to do a bit more testing before marking this ready for review though.This isn't a complete fix, because hydration will update the DOM piecemeal. That means that if you have something like this...
...the second paragraph will update immediately, while the second one will update once
condition
resolves. That's not what we want — we want those updates to be synchronized within a boundary. That will involve a little bit more footwork that's outside the scope of this PR, but which we'll get to soon.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint