导航ID不等于当前路由器导航ID错误 [英] Navigation ID is not equal to the current router navigation id error

查看:44
本文介绍了导航ID不等于当前路由器导航ID错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Angularv5 应用程序中使用 @ngrx/router-store,最近我开始遇到一个错误:Navigation ID X is not equal to the current navigation id Y(其中 X 和 Y 是整数).

I'm using @ngrx/router-store in my Angularv5 app and I recently started running into a an error: Navigation ID X is not equal to the current navigation id Y (where X and Y are integers).

当我从特定路线 B ​​导航到路线 A 时,始终会出现此问题.从任何其他路线导航到路线 A 似乎工作正常.

This problem happens consistently when I navigate to route A from a specific route B. Navigating to route A from any other route seems to work fine.

唯一的其他所以我发现与此相关的问题 提供了该问题可能是由于多次快速更新导航而引起的可能性.为了测试这是否发生(它不应该发生),我在我的根组件内订阅了路由器导航事件,在订阅内设置了一个断点,并打开了一个调试会话来逐步解决问题.这样做,我可以看到

The only other S.O. issue related to this which I've found, offers up the possibility that the issue could be caused by rapidly updating the navigation multiple times. To test if this was happening (it shouldn't be), I subscribed to router navigation events inside my root component, set a breakpoint inside the subscription, and opened up a debug session to step through the problem. Doing this, I can see that

  1. 说当前导航ID是11.当我导航到问题路线时,路由器开始导航,成功执行包括NavigationEnd在内的每个导航事件,然后立即@ngrx/router-store抛出一个 'ROUTER_CANCEL' 动作,声明:Navigation ID 12 不等于当前导航 ID 13.据我所知,12 是正确的导航 ID(同样,导航 ID 11 完成并立即抛出 'ROUTER_CANCEL' ,而路由器不会发出任何进一步的导航事件).此外,'ROUTER_CANCEL' 操作负载包含导致问题的路由器导航事件,以及导致问题时商店的状态.导致问题的事件的 ID 为 12,当时商店中的路由器状态的 ID 为 11.同样,12 似乎是正确的导航 ID,不应引发错误.

  1. Say the current navigation ID is 11. When I navigate to the problem route, the router starts navigation, successfully executes every navigation event including NavigationEnd and then immediately @ngrx/router-store throws an 'ROUTER_CANCEL' action stating that: Navigation ID 12 is not equal to the current navigation id 13. As far as I can tell, 12 is the correct navigation ID (again, navigation ID 11 completes and immediately 'ROUTER_CANCEL' is thrown without the router emitting any further navigation events). Furthermore, the 'ROUTER_CANCEL' action payload contains both the router navigation event that caused the problem, as well as the state of the store when the problem was caused. The event which caused the problem has an ID of 12, the router state in the store at the time had an ID of 11. So again, 12 seems to be the correct navigation ID and should not be throwing an error.

从问题路线导航到用户个人资料路线时,在@ngrx/router-store 取消导航之前不会发生其他导航.(即我没有快速更新导航路线)

On navigation to the user profile route from a problem route, no other navigation occurs until @ngrx/router-store cancels navigation. (i.e. I am not rapidly updating the navigation route)

除了 ngrx 分派 'ROUTER_CANCEL' 操作外,不会报告任何错误(也不会抛出任何错误).

Other than ngrx dispatching a 'ROUTER_CANCEL' action, no errors are reported (and no errors are thrown).

同样,遇到问题的路线工作正常,除非导航从特定路线 B ​​开始.据我所知,这条特定路线 B ​​没有什么不同或不寻常(问题路线 A 也不关心人们从哪里来from——两条路由没有关联).

Again, the route experiencing problems works fine unless navigation begins from a specific route B. As far as I can tell, there is nothing different or unusual about this specific route B (nor does the problem route A care where people are coming from--the two routes have no association with each other).

最后一件事:在调试会话之外触发错误似乎总是会导致Navigation ID X is not equal to the current navigation id X+1 形式的错误,但是在内部触发错误调试会话可能会导致 Navigation ID 11 is not equal to the current navigation id 15Navigation ID 13 is not equal to the current navigation id 20 等.

One last thing: triggering the bug outside of a debug session always seems to cause errors in the form Navigation ID X is not equal to the current navigation id X+1, however triggering the bug inside a debug session might cause Navigation ID 11 is not equal to the current navigation id 15 or Navigation ID 13 is not equal to the current navigation id 20, etc.

有人知道发生了什么吗?我对@ngrx/router-store 不够熟悉,无法真正猜测这可能是如何发生的.我的假设是,当@ngrx/router-store 接收到 NavigationEnd 事件时,商店中的导航 ID 值会同步增加,所以我什至不确定这些 ID 是如何永远em> 乱序——更不用说在这种情况下,ID 似乎是正确的.

Does anyone have any ideas what is going on? I'm not familiar enough with @ngrx/router-store to really guess how this might be happening. My assumption is that the navigation ID value in the store increases synchronously when NavigationEnd events are received by @ngrx/router-store, so I'm not even sure how the ids could ever get out of order---let alone in this case where the ids appear to be correct.

非常感谢任何想法!

PS:我很高兴发布代码,但我的应用很大,我不知道从何处触发此错误.

PS: I'm happy to post code, but my app is large and I don't have any clues as to where this bug is being triggered from.

推荐答案

我想通了!组件中有 代码,该代码在NavigationEnd 事件上调用router.navigate().所以答案类似于这个S.O.中的答案.问题(快速改变路线).

I figured it out! There was code in a component that was calling router.navigate() on a NavigationEnd event. So the answer was similar to the answer in this S.O. issue (rapidly changing the route).

这篇关于导航ID不等于当前路由器导航ID错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆