-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
area: routerfreq2: mediumhotlist: googlerouter: directivesRouterLink, RouterLinkActive, RouterOutlet etc.RouterLink, RouterLinkActive, RouterOutlet etc.router: guards/resolversrouter: navigation pipeevents/scheduleNavigation/transitions observableevents/scheduleNavigation/transitions observablestate: confirmedtype: bug/fix
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/routerIs this a regression?
Not sure, I haven't tested this behavior in previous versions.Description
When an error is thrown when the router outlet is activating, subsequent navigations may fail. To demonstrate this in a simple case, the minimal reproduction has a component that throws an error from inside the constructor. We have another component that links to the error prone one and has runGuardsAndResolvers set to 'always'. Finally, we have a listener in the main app component that listens for NavigationError events and redirects to the non-error component (in reality this would be a special error page).When you click the link to the error component it starts activating the router outlet but fails before it is fully activated. This triggers a NavigationError which is expected. But when navigating to the non-error component, it fails saying "Outlet is not activated". This is triggered by the getRouterGuards method inside preactivation.ts. In order to trigger this use case, you need to ensure that guards and resolvers are run on this navigation which is why runGuardsAndResolvers needs to be set to 'always'.
🔬 Minimal Reproduction
[https://stackblitz.com/edit/error-during-outlet-activation-uqvsad?file=src/app/app.component.ts](https://stackblitz.com/edit/error-during-outlet-activation-uqvsad?file=src/app/app.component.ts)🔥 Exception or Error
Error: Uncaught (in promise): Error: Outlet is not activated
Error: Outlet is not activated
at RouterOutlet.get [as component] (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/@angular/router@8.0.0/bundles/router.umd.js:5119:27)
at getRouteGuards (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/@angular/router@8.0.0/bundles/router.umd.js:3005:77)
at eval (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/@angular/router@8.0.0/bundles/router.umd.js:2968:13)
at Array.forEach ()
at getChildRouteGuards (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/@angular/router@8.0.0/bundles/router.umd.js:2967:29)
at getAllRouteGuards (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/@angular/router@8.0.0/bundles/router.umd.js:2937:16)
at MapSubscriber.eval [as project] (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/@angular/router@8.0.0/bundles/router.umd.js:3999:84)
at MapSubscriber._next (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/rxjs@6.5.2/internal/operators/map.js:49:35)
at MapSubscriber.Subscriber.next (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/rxjs@6.5.2/internal/Subscriber.js:66:18)
at TapSubscriber._next (https://error-during-outlet-activation-uqvsad.stackblitz.io/turbo_modules/rxjs@6.5.2/internal/operators/tap.js:65:26)
🌍 Your Environment
Angular Version:
8.0.0
Anything else relevant?
Metadata
Metadata
Assignees
Labels
area: routerfreq2: mediumhotlist: googlerouter: directivesRouterLink, RouterLinkActive, RouterOutlet etc.RouterLink, RouterLinkActive, RouterOutlet etc.router: guards/resolversrouter: navigation pipeevents/scheduleNavigation/transitions observableevents/scheduleNavigation/transitions observablestate: confirmedtype: bug/fix