-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: skip pending block for already-resolved promises #12274
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
Conversation
🦋 Changeset detectedLatest commit: e585b9f 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 |
As articulated in #11995 (comment) I'm still hesitant:
|
For hydration nothing changes, it will always start out by hydrating the pending block |
* feat: skip pending block for already-resolved promises * update tests * update docs
Now that we've made `mount` and `hydrate` not call `flushSync` anymore, we can go back to using `queue_microtask` inside `#await`, which means people who want to synchronously see the pending block can do so using `flushSync` (as validated by our tests). This essentially reverts #12274
Now that we've made `mount` and `hydrate` not call `flushSync` anymore, we can go back to using `queue_microtask` inside `#await`, which means people who want to synchronously see the pending block can do so using `flushSync` (as validated by our tests). This essentially reverts #12274
Replaces #11995 — since #11989, this is much easier to do. All we need is to replace
queue_micro_task(...)
withPromise.resolve().then(...)
.I think this makes sense, because there are plenty of reasons why a promise might be resolved on mount — a client-side cache, or a SvelteKit
load
function that returns a promise that resolves before hydration can occur. If we render the pending block in these cases, the best case is wasted effort; the worst case is visible glitchiness:But it does mean that
mount
is arguably not fully synchronous, which is a change. (For clarity: this only concernsmount
, the pending block is still rendered when hydrating.) And it means we'll have to update a whole bunch of tests, which I didn't want to do until we have a consensus that this is a sensible direction.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint