Skip to content

Angular routes with custom Resolve crashes the application if using the Back button #665

Open
@darind

Description

@darind

I have a simple nativescript application with 3 routes:

const routes: Routes = [
    { path: "", redirectTo: "/route1", pathMatch: "full" },
    { path: "route1", component: Route1Component },
    { path: "route2", component: Route2Component, resolve: { test: TestResolve } },
    { path: "route3", component: Route3Component }
];

where TestResolve is defined like this:

import { Injectable } from "@angular/core";
import { Resolve } from "@angular/router";

@Injectable()
export class TestResolve implements Resolve<string> {
    resolve() {
        return new Promise((resolve, reject) => {
            setTimeout(function() {
                resolve('we are done here');
            }, 3000);
        });
    }
}

Now I navigate from route1 to route2 and finally route3 within my application using simple links in the corresponding markup:

<Button [nsRouterLink]="['/route2']" text="go to route 2"></Button>

On route3 clicking the Back button multiple times quickly will crash the application with the following:

JS: EXCEPTION: Calling startGoBack while going back.
JS: ORIGINAL STACKTRACE:
JS: Error: Calling startGoBack while going back.
JS:     at NSLocationStrategy._beginBackPageNavigation (file:///data/data/org.nativescript.repro2/files/app/tns_modules/nativescript-angular/router/ns-location-strategy.js:129:19)
JS:     at Object.<anonymous> (file:///data/data/org.nativescript.repro2/files/app/tns_modules/nativescript-angular/router/page-router-outlet.js:189:40)
JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.repro2/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:190:28)
JS:     at Object.onInvoke (file:///data/data/org.nativescript.repro2/files/app/tns_modules/@angular/core/bundles/core.umd.js:4391:41)
JS:     at ZoneDelegate.invoke (file:///data/data/org.nativescript.repro2/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:189:34)
JS:     at Zone.runGuarded (file:///data/data/org.nativescript.repro2/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:97:47)
JS:     at Object.callback (file:///data/data/org.nativescript.repro2/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:73:29)
JS:     at Page.Observable.notify (file:///data/data/org.nativescript.repro2/files/app/tns_modules/tns-core-modules/data/observable/observable.js:149:23)
JS:     at Page.onNavigatedFrom (file:///data/data/org.nativescript.repro2/files/app/tns_modules/tns-core-modules/ui/page/page-common.js:234:14)
JS:     at Page.onNavigatedFrom (file:///data/data/org.nativescript.repro2/files/app/tns_modules/tns-core-modules/ui/page/page.js:131:42)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions