Skip to content

Probe in app runs a full navigation when a canMatch guard redirects #128

Closed

Description

@erkamyaman

Problem

"Probe in app" should run the matcher without navigating. It calls router.navigateByUrl(url, {skipLocationChange: true}) and aborts at RoutesRecognized (packages/ng-devtools/src/router-actions.ts:596-599, :621-623). It only listens to events for its own navigation id.

A canMatch guard can return a UrlTree, for example an auth guard that sends users to /login. In that case Angular cancels the probe navigation and schedules a new navigation to the redirect target (@angular/router 22.1.7 _router-chunk.mjs:2628-2633, :4024-4030, :4552-4563). The new navigation inherits skipLocationChange but has a different id. The probe resolves on the cancel and never aborts it. The redirect target then runs to completion. Its canActivate guards and resolvers run and its component renders. Only the URL bar stays the same.

This affects the docs and the config:

  • The router docs say probe does not run canActivate, canDeactivate or resolvers (apps/docs/src/content/inspectors/router.md, FAQ "Does Probe in app change the URL?"). The agent tools table says it runs "without navigating" (apps/docs/src/content/agents/tools.md:137).
  • actions: {router: false} does not block probe. ROUTER_WRITE_ACTIONS is ['navigate', 'abort', 'replay'] (packages/ng-devtools/src/config.ts:185, checked in devframe.ts:386-390). The button is not tied to navigationAllowed() either (app/src/pages/route-tree.ts:45). With navigation turned off, probe can still change the rendered page.

Steps to reproduce

  1. Add a route with canMatch: [() => inject(Router).parseUrl('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/login')].
  2. In the router inspector, enter that route's URL and click "Probe in app".
  3. The app now renders /login, but the address bar still shows the old URL.

Proposed scope

  • Make probe also abort a follow-up navigation that comes from a redirect of the probe (watch for RedirectRequest or the next navigation id). Report the redirect target as the result.
  • Test with a canMatch guard that returns a UrlTree and one that returns a RedirectCommand.

Activity

  1. added
    bug
    P2
    needs triage
    area: package
    on Sep 30, 2026
  2. self-assigned this
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2area: packagebugneeds triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions