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

Navigating to error page from error handler when error thrown in ngOnInit #16246

jonmikelm opened this Issue Nov 6, 2018 · 3 comments


None yet
3 participants

jonmikelm commented Nov 6, 2018

Bug Report

Ionic Info
Run ionic info from a terminal/cmd prompt and paste the output below.


   ionic (Ionic CLI)             : 4.2.1 (D:\Users\******\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.15
   @angular-devkit/build-angular : 0.7.5
   @angular-devkit/schematics    : 0.7.5
   @angular/cli                  : 6.2.5
   @ionic/angular-toolkit        : not installed


   NodeJS : v10.11.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 7

Describe the Bug
When an error is thrown in the ngOnInit method of a page component, and a custom error handler is defined to redirect to an error page, both the page that generated the error and the error page are rendered inside the ion-router-outlet.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Navigate to a page, e.g:
  1. Throw an error in ngOnInit
ngOnInit() {
  throw 'error';
  1. Handle the error in a custom angular error handler
public handleError(error: any): void {
  const navCtrlr = this.injector.get(NavController); => {
  1. Inspect DOM and verify that ion-router-outlet contains both components, with page1 on top.

Related Code

Expected Behavior
The navigation to page1 should be canceled and the component removed from outlet. The error page should be shown.

Additional Context
I've tried with and without using ngZone while navigating in the custom error handler but the result is the same.
This old angular issue is closed but problems can be related:

@ionitron-bot ionitron-bot bot added the triage label Nov 6, 2018


This comment has been minimized.

selipso commented Nov 6, 2018

Have you tried using a route guard? It seems like that would be a more appropriate method for what you are trying to achieve.


This comment has been minimized.

almothafar commented Nov 7, 2018

I feel it could be a side effect for the router issues that appeared with beta 15, do you have the same issue in beta 13? look at #16244


This comment has been minimized.

jonmikelm commented Nov 7, 2018

I've just tested it with beta 13 and the result is the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment