fix: pending requests after module invalidation#7283
Merged
Conversation
bluwy
approved these changes
Mar 13, 2022
4 tasks
7 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Continuation on the work started by #7254
When we invalidate a module, we don't cache results for in-fly requests after #7254.
We also cache pending requests so we can collapse requests for the same resource while processing. This is important due to the way Vite crawls the whole module graph eagerly even before the browser does the requests.
After invalidation, we need to also consider the case
This PR fixes this case. This is another case that is difficult to test and reproduce, so users may have run against it without being able to send the report.
@antfu I didn't use AbortController as we need Node 15 IIUC. It could be interesting to save the promise in the Module instead of in
_pendingRequeststhat would lead to a similar scheme like you proposed but looks like we may not always have a Module since we only create it in the module graph after a successful load (so in the middle of the processing). Maybe we could create a Module upfront and keep it in amoduleGraph._pendingand only add it after load. Maybe we could do this refactoring in another PR.What is the purpose of this pull request?