-
-
Notifications
You must be signed in to change notification settings - Fork 241
Occasional crash in NSRouteReuseStrategy.shouldAttach() #1048
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
Comments
After upgrading our app from NativeScript 3.1 to 3.2 (or 3.3) we are facing the same issue when we use the back button on android afer the user opened a deep link.
|
This is also happening in our app with NativeScript 3.2 and 3.3 on iOS. When routing to a page using a deep link and then clicking the back button: Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'this.cache.peek().key')
shouldAttach@file:///app/tns_modules/nativescript-angular/router/ns-route-reuse-strategy.js:64:55
activateRoutes@file:///app/tns_modules/@angular/router/./bundles/router.umd.js:4743:57
file:///app/tns_modules/@angular/router/./bundles/router.umd.js:4715:72
forEach@[native code]
activateChildRoutes@file:///app/tns_modules/@angular/router/./bundles/router.umd.js:4715:36
activateRoutes@file:///app/tns_modules/@angular/router/./bundles/router.umd.js:4736:41
file:///app/tns_modules/@angular/router/./bundles/router.umd.js:4715:72
forEach@[native code] |
After more debugging I've found that this will happen on a back route after a clear history. EDIT:
So when we start a navigate command with the clearCache: true flag it will first push the two next routes in the cache and only after the navigation is done it will perform the clear cache. EDIT 2:
|
using the same check for an empty cache as used in the retrieve() method.
This also happens to my app. When user logined, we will redirect the user to home page with a clearHistory flag. If the user then hitting whatever redirection buttons on the home page as fast as they can, they will run into this issue when they try go back. The issue is raised by the usage of setTimeout. Any particular reason to use setTimeout?
|
With NS 5.3.1 and NS-Angular 7.2.3 we are seeing similar behaviour again on back routing after a clearHistory. But instead of the app crashing we end up with a blank page. I've created a sample application that shows the same behaviour. If you open this app it will navigate from the home to a second page (with a pink background) and then to a third page with a blue background. If you then navigate back the second page (pink one) is empty (blank). In our production app I could fix this behaviour by changing the loadComponentInPage function of the PageRouterOutlet.
I just removed the setTimeout call around the callback function. |
I am having same issue as well |
I had this issue if I called |
I had this issue if I called routerExtensions.back() too many times...
|
is there any improvement on this subject? |
Workaround:
|
Sometimes after debugging for a while, I get a crash when going back from a page. The error says key is not defined in
NSRouteReuseStrategy.shouldAttach()
here:const shouldAttach = isBack && this.cache.peek().key === key;
I see in other places nearby there is a check that
this.cache.peek()
exists before calling .key.The text was updated successfully, but these errors were encountered: