-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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(router): unsubscribe preload if the route has been preloaded #26557
Conversation
Thanks for the PR. Can you please add a test? I would like to confirm this was failing in the past. Looking at the code, I see a |
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.
See comment about adding tests to confirm this is currently broken and this fixes it.
I already made stackblitz to reproduce the issue, so you should be able to confirm the issue there. |
Add four 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
Store an observable on the route for the currently outstanding module load factory. The replaces the fix angular#26557 as that allowed overlapping requests to still load the module twice. Fixes angular#26557 angular#22842
Add four 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
Store an observable on the route for the currently outstanding module load factory. The replaces the fix angular#26557 as that allowed overlapping requests to still load the module twice. Fixes angular#26557 angular#22842
Add four 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
Store an observable on the route for the currently outstanding module load factory. The replaces the fix angular#26557 as that allowed overlapping requests to still load the module twice. Fixes angular#26557 angular#22842
Add four 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
Store an observable on the route for the currently outstanding module load factory. The replaces the fix angular#26557 as that allowed overlapping requests to still load the module twice. Fixes angular#26557 angular#22842
Clear the stored loader promise so that subsequent load will try the fetch again. The restores the same behaviour as before we cached the loader to fix angular#26557
Closing due to the issues mentioned in #36760
|
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. |
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 * Clear the stored loader promise so that subsequent load will try the fetch again. The restores the same behaviour as before we cached the loader to fix angular#26557
Store an observable on the route for the currently outstanding module load factory. The replaces the fix angular#26557 as that allowed overlapping requests to still load the module twice. Fixes angular#26557 angular#22842
Clear the stored loader promise so that subsequent load will try the fetch again. The restores the same behaviour as before we cached the loader to fix angular#26557
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 * Clear the stored loader promise so that subsequent load will try the fetch again. The restores the same behaviour as before we cached the loader to fix angular#26557
Store an observable on the route for the currently outstanding module load factory. The replaces the fix angular#26557 as that allowed overlapping requests to still load the module twice. Fixes angular#26557 angular#22842
Clear the stored loader promise so that subsequent load will try the fetch again. The restores the same behaviour as before we cached the loader to fix angular#26557
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 * Clear the stored loader promise so that subsequent load will try the fetch again. The restores the same behaviour as before we cached the loader to fix angular#26557 * Add error handle error from loadChildren * Ensure we handle error from with NgModule create
Store an observable on the route for the currently outstanding module load factory. The replaces the fix angular#26557 as that allowed overlapping requests to still load the module twice. Fixes angular#26557 angular#22842
Clear the stored loader promise so that subsequent load will try the fetch again. The restores the same behaviour as before we cached the loader to fix angular#26557
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
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
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
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
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
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
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
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
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
#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
#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
#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
#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
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?
When a lazyloaded route is loaded with a user interaction for example, the observable returned by
preload
from aPreloadingStrategy
is not unsubscribed. Which do not stop the preload strategy from loading the module again.This basic preload strategy load the module twice if the user navigate to the route before 5 seconds:
Reproduced here: https://stackblitz.com/edit/angular-preload-issue
Step to reproduce:
What is the new behavior?
Cancel the preload observable if the route is loaded.
Does this PR introduce a breaking change?
Other information
Also, the observable returned by
load()
is not cold, the loading start when the function is called, even if the observable is not subscribed. Is this intended ?angular/packages/router/src/router_config_loader.ts
Lines 47 to 60 in c9488b5
this.loader.load(loadChildren)
should be wrapped inside an observable.