question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cancelling a navigation instruction with a redirect raises inconsistent navigation events

See original GitHub issue

I’ve tested the new navigation events (processing -> success|error|canceled -> compete) using the routing pipeline steps as described in the documentation, but the new router does not seem to raise consistent events when redirecting from a pipeline step.

When redirecting from /welcome to /login in the authorize pipeline step, the router:navigation:success and router:navigation:complete events are fired with the /welcome instruction, no other events are raised in regards to the redirection/navigation to /login, but the redirection does happen (original example in PR https://github.com/aurelia/router/pull/97).

This causes issues when components subscribe to these events to change their appearance/behaviour, because the application ends up onto the /login page correctly, but the components receive the event telling them they are on the /welcome page.

This is what I see in the logs when I listen to the events and I log when the redirection happens in my authorize pipeline step:

processing   /welcome
redirect     /login
success      /welcome
complete     /welcome

I’ve tried the same logic but using canActivate in the welcome controller, which results in the same outcome above.

canActivate(params) {
    return new Redirect("login");
}

In the events’ data received (success and complete), the result is stating that the status of the navigation is completed, and the event instruction is /welcome, while the browser is showing /login.

From the event handler perspective, there is no way to determine or being notified what the actual final view is, in this case /login.

As a minor side note, for a cancelled event, result.status states cancelled, but the event name is spelled in American English: canceled.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
aozisikcommented, Mar 21, 2016

Any progress on this issue? I have also hit the same wall

0reactions
RomkeVdMeulencommented, Jun 22, 2018

@Alexander-Taran It is: just ran into this specific problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2.0.0 Milestone · GitHub
Cancelling a navigation instruction with a redirect raises inconsistent navigation events bug enhancement. #177 opened on Aug 6, 2015 by bfil.
Read more >
Why Response.Redirect causes System.Threading ...
Redirecting in an event handler is ugly because you are terminating a partially generated page in order to generate a different page. MVC...
Read more >
Detect and get rid of unwanted sneaky mobile redirects
But redirecting mobile users sneakily to a different content is bad for ... Check if you are redirected when you navigate to your...
Read more >
NavigationCancel - Angular
An event triggered when a navigation is canceled, directly or indirectly. This can happen for several reasons including when a route guard returns...
Read more >
Track Events with Google Analytics 4 (GA4) and Google Tag ...
By the way, nav means “navigation” in this context. Great! Now I'll use this in my Just Links trigger. Go back to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found