Skip to content

fix(router): state is not guarded before use #1331

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

Merged
merged 1 commit into from
May 21, 2018

Conversation

DickSmith
Copy link
Contributor

@DickSmith DickSmith commented May 17, 2018

state is not guarded before use, but peekState may return null.

Appears to have been introduced here.
Before those changes, state was guarded.

May result in the following stack, seen on some older iOS devices (2-3 years) when rapidly navigating:

CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:1682:24: ERROR TypeError: undefined is not an object (evaluating 'state.isPageNavigation')
CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:1682:24: ERROR TypeError: undefined is not an object (evaluating 'state.isPageNavigation')
CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:1682:24: ERROR Error: Uncaught (in promise): TypeError: null is not an object (evaluating 'state.isRootSegmentGroup')
path@file:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:33:18
get@file:///app/tns_modules/nativescript-angular/router/ns-platform-location.js:38:46
path@file:///app/tns_modules/@angular/common/bundles/common.umd.js:589:46
path@file:///app/tns_modules/@angular/common/bundles/common.umd.js:247:58
isCurrentPathEqualTo@file:///app/tns_modules/@angular/common/bundles/common.umd.js:260:25
file:///app/tns_modules/@angular/router/bundles/router.umd.js:4158:56
file:///app/tns_modules/rxjs/internal/Observable.js:203:25
__tryOrUnsub@file:///app/tns_modules/rxjs/internal/Subscriber.js:263:20
next@file:///app/tns_modules/rxjs/internal/Subscriber.js:201:34
_next@file:///app/tns_modules/rxjs/internal/Subscriber.js:139:30
next@file:///app/tns_modules/rxjs/internal/Subscriber.js:103:23
_next@file:///app/tns_module

`state` is not guarded before use, but `peekState` may return null.

Appears to have been introduced [here](NativeScript@b98da83#diff-a7820fa2a2eb0ce14f3f0b8bfc666dd5R49).
Before those changes, `state` was guarded.

May result in the following stack, seen on some older iOS devices (2-3 years) when rapidly navigating:
```
CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:1682:24: ERROR TypeError: undefined is not an object (evaluating 'state.isPageNavigation')
CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:1682:24: ERROR TypeError: undefined is not an object (evaluating 'state.isPageNavigation')
CONSOLE ERROR file:///app/tns_modules/@angular/core/bundles/core.umd.js:1682:24: ERROR Error: Uncaught (in promise): TypeError: null is not an object (evaluating 'state.isRootSegmentGroup')
path@file:///app/tns_modules/nativescript-angular/router/ns-location-strategy.js:33:18
get@file:///app/tns_modules/nativescript-angular/router/ns-platform-location.js:38:46
path@file:///app/tns_modules/@angular/common/bundles/common.umd.js:589:46
path@file:///app/tns_modules/@angular/common/bundles/common.umd.js:247:58
isCurrentPathEqualTo@file:///app/tns_modules/@angular/common/bundles/common.umd.js:260:25
file:///app/tns_modules/@angular/router/bundles/router.umd.js:4158:56
file:///app/tns_modules/rxjs/internal/Observable.js:203:25
__tryOrUnsub@file:///app/tns_modules/rxjs/internal/Subscriber.js:263:20
next@file:///app/tns_modules/rxjs/internal/Subscriber.js:201:34
_next@file:///app/tns_modules/rxjs/internal/Subscriber.js:139:30
next@file:///app/tns_modules/rxjs/internal/Subscriber.js:103:23
_next@file:///app/tns_module
```
@ghost ghost added the ♥ community PR label May 17, 2018
@manoldonev manoldonev requested a review from MartoYankov May 18, 2018 13:40
@manoldonev
Copy link
Contributor

test

@dtopuzov dtopuzov added this to the 6.0 milestone May 21, 2018
@sis0k0 sis0k0 merged commit d27a893 into NativeScript:master May 21, 2018
@ghost ghost removed the ♥ community PR label May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants