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 module loading to ensure each module is loaded only once #40389
Conversation
b92ca0e
to
d55ddad
Compare
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 - Thanks for resubmitting this PR with the updates! A few small nits in the test and one question about finding a strategy to avoid using share
but otherwise LGTM
ab94772
to
38081cf
Compare
@pgammans one more thing - could you squash all of your commits into one? |
38081cf
to
7df432a
Compare
c814d22
to
867ac5c
Compare
Hi @pgammans - sorry for the slow response. After running internal tests, the approach we made to avoid introducing the I don't know if we can justify the additional payload size increase to address this edge case where a preloader and a navigation duplicate the loading of a lazy route. That would increase the payload for everyone and only prevent an extra load of a lazy module in a rare scenario so I think the cost-benefit doesn't quite work out in our favor. What we can certainly do now though is keep the check that you added in |
@atscott can i ask what the failure was and to see if i can develop a third solution that addresses all the issues. Obviously share does something that addresses this issue it may be possible to implement a fix for this without all the overheads that the generic share function will need to address and
Even this may be smaller as remove some of share features. |
@pgammans - I haven't been able to debug the exact issue internally so I unfortunately can't provide much more information now. It's a few of the application's webdriver integration test that are failing and I'll have to figure out how to spin up the app locally to debug it. |
ce0954b
to
6ac2011
Compare
@atscott |
// Use custom ConnectableObservable as share increasing the bundle size too much | ||
route._loader$ = | ||
new ConnectableObservable( | ||
moduleFactory$.pipe( |
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.
suggestion: What do you think of extracting this first argument of the ConnectableObservable
to a variable so it's easier to see the two arguments?
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've push a change for this and rebased to master.
I'm not 100% sure i agree as i think it breaks the link that the effective 'share' is part of the loader, but i can see an argument for separation of the loader from the share.
@pgammans - Yep, I believe you are correct. It looks like the goldens also already have the refcount operator. I want to run some final tests on this but at the moment it's looking good. Thanks for the work on this! |
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.
Reviewed-for: size-tracking
Fix router to ensure that a route module is only loaded once especially in relation to the use of preload strategies with delayed or partial loading. Add test to check the interaction of PreloadingStrategy and normal router navigation under differing scenarios. Checking: * Prevention of duplicate loading of modules. related to angular#26557 * Prevention of duplicate RouteConfigLoad(Start|End) events related to angular#22842 * Ensuring preload strategy remains active for submodules if needed The selected preload strategy should still decide when to load submodules * Possibility of memory leak with unfinished preload subscription related to angular#26557 * Ensure that the stored loader promise is cleared so that subsequent load will try the fetch again. * Add error handle error from loadChildren * Ensure we handle error from with NgModule create Fixes angular#26557 angular#22842 angular#26557
63cef5c
to
275fd78
Compare
@petebacondarwin I have applied your suggested commit for the spelling mistake, rebased onto master. I have also squashed all the commits as I assume this would be wanted. |
@atscott the size of aio-local-viewengine has also increased do you want a commit to increase ti size too? expected 432078, actual: 432647 so an increase of 569 bytes |
#40389) Fix router to ensure that a route module is only loaded once especially in relation to the use of preload strategies with delayed or partial loading. Add test to check the interaction of PreloadingStrategy and normal router navigation under differing scenarios. Checking: * Prevention of duplicate loading of modules. related to #26557 * Prevention of duplicate RouteConfigLoad(Start|End) events related to #22842 * Ensuring preload strategy remains active for submodules if needed The selected preload strategy should still decide when to load submodules * Possibility of memory leak with unfinished preload subscription related to #26557 * Ensure that the stored loader promise is cleared so that subsequent load will try the fetch again. * Add error handle error from loadChildren * Ensure we handle error from with NgModule create Fixes #26557 #22842 #26557 PR Close #40389
…trategies (angular#40389)" This reverts commit e9a19a6.
FYI - this fix was reverted as there were internal failures during the sync that need further investigation. |
Okay, so the issue is that by de-duplicating the module loading and using the same router config objects, we change how routes are re-used. That is, an |
Update: There was only one test failure (the one from yesterday) in the global test results. That indicates the issue isn't widespread enough to require further action other than a fix to this one test. After that is done, we can resubmit this PR. |
caretaker note: Since this PR previously had to be rolled back, I think it'd be a good idea to merge and sync on its own. |
#40389) Fix router to ensure that a route module is only loaded once especially in relation to the use of preload strategies with delayed or partial loading. Add test to check the interaction of PreloadingStrategy and normal router navigation under differing scenarios. Checking: * Prevention of duplicate loading of modules. related to #26557 * Prevention of duplicate RouteConfigLoad(Start|End) events related to #22842 * Ensuring preload strategy remains active for submodules if needed The selected preload strategy should still decide when to load submodules * Possibility of memory leak with unfinished preload subscription related to #26557 * Ensure that the stored loader promise is cleared so that subsequent load will try the fetch again. * Add error handle error from loadChildren * Ensure we handle error from with NgModule create Fixes #26557 #22842 #26557 PR Close #40389
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
This PR addresses the issues found in the issues #22842, PR #26557, PR #36760, PR #26557
It also replaces the PR for #26557 which has a number of issues and is an
By forcing the subscription to close if a module has a lazy sub-module then the these are passed to the PreloadingStrategy class as the observable has already terminated.
It doesn't actually prevent the load as the fetch may overlap with the preload fetch. Ie both the pre-loader and navigation can start a load both will finish.
Issue Number: #26557, #22842
What is the new behavior?
By Prevent loading a route module twice, we prevent the sending of multiple RouteConfigLoadEnd events, and the duplicate console log as show in the stackbiz example on #26557
Does this PR introduce a breaking change?
Other information
This is an updated version of my originally and closed PR #36760 (due to my failure to update) but addressing @atscott comments.