Skip to content
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

Regression routerNavigateByUrl + canLoad in 7.0-rc.0 <> 6.1 #26284

Closed
timdeschryver opened this issue Oct 6, 2018 · 4 comments
Closed

Regression routerNavigateByUrl + canLoad in 7.0-rc.0 <> 6.1 #26284

timdeschryver opened this issue Oct 6, 2018 · 4 comments
Assignees
Labels
area: router regression Indicates than the issue relates to something that worked in a previous version
Milestone

Comments

@timdeschryver
Copy link
Contributor

I'm submitting a...


[x] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

When calling router.navigateUrl('/route').then(...) in combination with a canLoad guard that returns false, the Promise isn't getting resolved (then function isn't getting invoked).

Expected behavior

If this is the desired result, this is OK for me 😅
I just wanted to be sure of this, because this was working in v6.1

Minimal reproduction of the problem with instructions

There is a guard on the lazy route which returns false. When we click on the button it tries to navigate to the lazy loaded module guarded by a canLoad guard.

this.router.navigateByUrl('/lazy').then((result) =>{
      console.log('ok:', result);
    }).catch(err => {
      console.log('catch:', err);
});

Notice that in v6.1 it logs ok: false whereas in v7.0 it does not.
(After clicking it 3 times, the guard does return true).

Version 6.1: https://stackblitz.com/edit/load-guard-6?file=src%2Fapp%2Fapp.module.ts

angular6

Version 7.0-rc.0: https://stackblitz.com/edit/load-guard-7?file=src%2Fapp%2Fapp.module.ts

angular7

What is the motivation / use case for changing the behavior?

I encountered this while upgrading the NgRx repo to the rc version and encountered this issue in our tests - ngrx/platform#1354 (comment)

Environment


Angular version: 7.0-rc.0


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

I'm not sure but I think this behavior comes from throwing an error at https://github.com/angular/angular/blob/master/packages/router/src/apply_redirects.ts#L90 but not catching it and dispatching a NavigationCancel event at https://github.com/angular/angular/blob/master/packages/router/src/router.ts#L410.

@ngbot ngbot bot added this to the needsTriage milestone Oct 8, 2018
@jasonaden jasonaden added the regression Indicates than the issue relates to something that worked in a previous version label Oct 8, 2018
@jasonaden
Copy link
Contributor

Thanks for the issue and for looking into it. We'll pull this in to get fixed ASAP.

@timdeschryver
Copy link
Contributor Author

Thanks @jasonaden !

@JounQin
Copy link
Contributor

JounQin commented Nov 6, 2018

Seems like #26757 which still does not work for now.

FrederikSchlemmer pushed a commit to FrederikSchlemmer/angular that referenced this issue Jan 3, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: router regression Indicates than the issue relates to something that worked in a previous version
Projects
None yet
3 participants