{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Fix module loading to ensure each module is loaded only once #40389
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
Closed
Closed
Changes from all commits
Commits
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 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
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
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
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
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
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
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
Oops, something went wrong.
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.
You can’t perform that action at this time.

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.
Now that this is no longer a
replay, does it make sense to return theroute._loadedConfiginstead if it exists or check if theroute._loader$is already complete? The callers ofloadhere prevent this from being the case, but it might still be a good safeguard. 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.
Yes we need to return
route._loadedConfigbut asroute._loadedConfigwill only exist onceroute._loader$is complete.Currently it is the callers of load need to set
route._loadedConfigthemselves. which is a bit odd and and addressed in #36654The callers are (possibly more)
RouterPreloader.preloadConfigApplyRedirects.getChildConfigApplyRedirects.matchSegmentAgainstRouteThe first two have checks for
route._loadedConfigand use that if available so load will not get called in these cases. The later is probably should be updated to but atm the check in load would prevent duplicate loadsLastly in the delay between create and compete of
route._loader$we need to use the same observable if load is called multiple times. Which it can be as, in fact we have test that do this.ie there can be a call from multiple of the load callers. In the test we have one from the call
RouterPreloader.preloadConfigand on from the call throughApplyRedirects.getChildConfigThere 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 absolutely agree that it's odd for the callers of
loadto set_loadedConfigrather than havingRouteConfigLoaderand I like the direction of #36654.Since
RouterConfigLoaderisn't public API and neither are the callers ofload, I'll leave it to you to decide which approach to take to ensure we aren't returning the already completed_loaderobservable:loadfunction in the same manner the callers are doing by checking for_loadedConfigApplyRedirectsto not callloadif_loadedConfigalready exists.We can then consolidate everything in #36654 or in another PR that omits the
RouteConfigReadyfeature and only improves the DRY-ness (would be easier to land, as it's not a public api change).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.
@atscott Ideally I think we should put the test
route._loadedConfiginside load, and move it setting to part of the load, butapply_redirectsuse the status ofroute._loadedConfigto avoid duplicating calls to the load guard.Thus we'd need some another call to allow us prevent calling the guard twice. ie would probably need to be change to public API of Route!
So i propose: (basically what we have.)
route._loadedConfigOnce landed look at improving setting of
route._loadedConfigto be part of the loads. observable pipe (new PR based on #36654)I added a check to
ApplyRedirects.matchSegmentAgainstRouteand a test using this code path.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.
@pgammans - 👍 Agreed.
I think maybe you forgot to push up your changes to
ApplyRedirects.matchSegmentAgainstRoute? After that's done, I'll run a final sanity check suite of internal tests and this should be good to go! Thanks for the hard work!