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

查看:325
本文介绍了导航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 is not equal to the current navigation 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的路线也不在乎人们要去哪里来自-两条路线没有关联).

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).

最后一件事:在调试会话之外触发bug似乎总是会导致Navigation ID X is not equal to the current navigation id X+1形式的错误,但是在调试会话内部触发bug可能会导致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如何永远顺序---在这种情况下,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.

任何想法都将不胜感激!

Any thoughts are greatly appreciated!

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天全站免登陆