feat: skip pending block for already-resolved promises #12274
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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