Skip to content

Internal router transition Subject has stale state #30340

Closed

Description

@jasonaden

Navigations are initialized by sending a new value into Router.transitions. In order to do so, we take the new value and merge it with the previous value. However, that previous value will always be the previous value prior to navigations having been run.

The real data we need is the NavigationTransition that most recently passed to the subscribe on Router.navigations. This will contain reference to the recent urlAfterRedirects and any other data added to the transition through the process of navigating.

Starting with old values can produce incorrect behavior. For instance, a test in Google navigates to a route, then navigates to the same route again, which in the router codebase falls into a path that essentially marks it to do nothing. Upon marking it to do nothing, we attempt to get the state right for the next navigation. However, the value is stale due to the above description.

The next navigation they are performing in the test is hitting back, which goes to the root. Because they happened to start on root, then navigate twice to the same place, then specifically go back to the root again, the back operation does nothing because the router thinks it’s already there.

Activity

  1. added this to the Backlog milestone on May 8, 2019
  2. jasonaden commented on May 8, 2019

    @jasonaden
    ContributorAuthor

    When fixed, need to un-revert this PR and verify this set of tests pass.

  3. added a commit that references this issue on May 15, 2019
    9b88920
  4. added a commit that references this issue on May 21, 2019
    882e0db
  5. broweratcognitecdotcom commented on Jul 31, 2019

    @broweratcognitecdotcom

    I see a difference in behavior betwen ng6 and ng8 and I am wondering if it is because of these changes. In ng6, navigating to the same route for the purposes of updating the query params did not trigger NavigationStart and NavigationEnd events. In ng8 it is so that navigating to the same route for the purposes of updating the query params does trigger NavigationStart and NavigationEnd events. Was this behavior change intended?

  6. angular-automatic-lock-bot commented on Sep 15, 2019

    @angular-automatic-lock-bot

    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.

  7. locked and limited conversation to collaborators on Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions