Skip to content

Router: flag redirect loops in the navigation timeline #39

Description

@erkamyaman

The problem

Redirect loops are hard to spot in the router timeline.

  • The route lint already flags redirect cycles in the config (redirectTo pointing back and forth).
  • The timeline shows "redirected from #N" on each navigation, so you can follow a chain by hand.

What neither catches is a loop made by guards. For example, an auth guard sends /account to /login, and a guard on /login sends a signed-in user back to /account. Each hop looks normal on its own, and the timeline just fills up with navigations.

What we need

  • Detect loops at runtime: follow redirectedFrom through recent navigations and flag a chain where the same URL shows up twice.
  • Show it in the timeline: mark the navigations in the loop, show the chain (/account → /login → /account), and name the guard or redirectTo behind each hop when it's known.
  • Lint: add a redirect-loop finding with the chain and the guards involved.
  • MCP: include the loop in explain-navigation and export-navigation, and in the lint tool, so agents can explain it.
  • Tests: a guard-to-guard loop, a redirectTo loop, and a long chain that isn't a loop (no false positives).

Notes

  • Guard results are recorded when router recording is on (on by default in dev), so the chain can say which guard redirected.
  • Angular stops real infinite loops with NG04016; this should catch the loop before that point too, including loops that end after a few bounces.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions