-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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(server-renderer): Fix call to serverPrefetch in server renderer with an async setup #10893
Merged
yyx990803
merged 6 commits into
vuejs:main
from
deleteme:fix-waiting-for-serverPrefetch-in-server-renderer
Sep 3, 2024
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
abc54c6
test(server-renderer): create serverPrefetch w/async setup test case
deleteme a6f421f
fix(server-renderer): Fix renderComponentVNode to call serverPrefetch…
deleteme 4ec094b
fix(server-renderer): refactor renderComponentVNode to be async and s…
deleteme 7af4f77
fix(server-renderer): undo async renderComponentVNode, preserve fast …
deleteme e159b16
fix(server-renderer): simplify logic, remove two promises
deleteme 7bf6732
fix(server-renderer): guard reassignment of prefetches behind hasAsyn…
deleteme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
It seems
getPrefetches
will be called twice, ifhasAsyncSetup
equalsfalse
. I think this should be avoided.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.
Reading
instance.sp
only once and caching that value to be used after set up resolves is what caused the bug.What is the concern about accessing
instance.sp
twice?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.
@edison1105 I pushed a commit which:
renderComponentVNode
async. It now always returns a promise.await
directly on thesetupComponent
call. No need to inspect it to see if it is a promise.instance.sp
once, after setup.Please let me know if this is what you had in mind. This extra commit is more involved.
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.
I'm not sure if it's reasonable to change
renderComponentVNode
to async. see #11340 (comment)Let's wait for reviews from other team members
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.
@edison1105 Ok, I see that there is deliberate synchronous fast paths in place. In that case, I'm happy to revert the last commit or do whatever is needed here.
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.
Maybe we could change it like below, what do you think?
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.
@edison1105 I pushed up that change in 7af4f77, and then I went a little further and optimized away
two promisesone promise in e159b16.Removes the unnecessary
hasAsyncSetup
ternary conditional by usingPromise.resolve
directly around theres
object because it returns the exact same promise if it is given one.Removes a new promise by removing a
.then
callbackRemoves another new promise by removing aEdit: I was mistaken about this change; It isn't pushed, nor needed here..catch
callback in favor of assigning the noop as the second argumentSo maybe this will be a little faster or at least produce a little less garbage.