Skip to content

fix(router): report the skip when probing the current URL - #250

Merged
erkamyaman merged 2 commits into
mainfrom
fix/router-probe-current-url
Oct 11, 2026
Merged

erkamyaman merged 2 commits into
mainfrom
fix/router-probe-current-url

Conversation

@erkamyaman

@erkamyaman erkamyaman commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

What and why

The router probe action checks whether a URL matches without really navigating. It calls router.navigateByUrl(url, { skipLocationChange: true }) and then reads the new navigation id into targetId. Its event handler ignores any event whose id isn't targetId.

When the probed URL is the one the router is already on (with the default onSameUrlNavigation: 'ignore'), Angular emits NavigationSkipped synchronously inside navigateByUrl. At that point targetId is still -1, so the event is dropped and nothing else follows. The probe waits the full 10 seconds and answers "The probe did not finish within 10s." instead of saying the navigation was skipped. Probing the current URL is a natural first thing for an agent to try.

The fix:

  • sets targetId to the next navigation id before calling navigateByUrl, keeping -1 when the id can't be read
  • starts the 10s timer before navigating, so a probe that finishes synchronously clears it instead of leaving it to abort some later navigation

How it was verified

Added a test to router-features.test.ts on the real Router setup. It navigates to /users/8, probes /users/8 with fake timers, and expects { matched: false, reason: /ignored/ } with no timeout error. On main it fails with expected 'The probe did not finish within 10s.' to be undefined. With the fix it passes and the router stays on /users/8. Like the other probe tests, it is skipped on Angular versions before 20.2.

  • pnpm commit:check (commit messages follow the guidelines)
  • pnpm format:check
  • pnpm typecheck (includes the ngc template checks)
  • pnpm test:devtools (all passing)
  • pnpm skills:check (when .claude/ changed): not changed
  • No docs change needed: a bug fix with no change to options or labels (no-docs)
  • pnpm extension:build and extension/ui committed (when app/ changed): not changed
  • Checked in the browser with axe (when the UI changed): no UI change

Summary by CodeRabbit

  • Bug Fixes
    • Router probes now handle ignored navigation attempts without timing out, while preserving the current route.
    • Probe timeouts are started before navigation begins, improving handling of navigation IDs.

The probe action set the navigation id it listens for only after calling
navigateByUrl. When the URL is the one the router is already on, Angular
emits NavigationSkipped synchronously inside that call, so the probe
ignored it and waited the full 10 seconds before answering that it did not
finish. The id is now set, and the timeout started, before navigating, so
the probe answers right away with the skip reason.
@erkamyaman erkamyaman added the no-docs This pull request needs no docs change (the reason is in the description) label Oct 10, 2026
@github-actions github-actions Bot added the area: package The ng-devtools package (packages/ng-devtools) label Oct 10, 2026
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 98fc4c0f-b79e-400c-83d8-ef89669d3164

📥 Commits

Reviewing files that changed from the base of the PR and between 9ec73d8 and bb3f361.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 80321554-e01c-4c27-9bb2-6ca4cbff5a1a


📥 Commits

Reviewing files that changed from the base of the PR and between f245551 and 9ec73d8.



📒 Files selected for processing (2)
  • packages/devtools/src/__tests__/router-features.test.ts
  • packages/devtools/src/router-actions.ts


Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The router probe now sets its timeout and target navigation ID before navigation. A test checks the result of probing the URL already active in the router.

Changes

Router probe

Layer / File(s) Summary
Set probe timing before navigation
packages/devtools/src/router-actions.ts, packages/devtools/src/__tests__/router-features.test.ts
probe sets its timeout and target navigation ID before calling navigateByUrl. The test checks that probing the active URL returns an unmatched result with an ignored-navigation reason and leaves the router URL unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix



Merge Risk: ⚪ Minimal · up to 9ec73

Probing the URL that is already active now reports that the navigation was ignored, instead of timing out after 10 seconds. No merge-blocking risk remains.

Architecture Summary

Architecture risk: 🔵 Low · up to 9ec73

The change affects 1 system.

Changed systems: packages/devtools

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/devtools (library) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/devtools/src/tests/router-features.test.ts: The Vitest import adds vi.
  • observed — Modified behavior in packages/devtools/src/tests/router-features.test.ts: Adds an Angular 20.2+ test for probing the URL already active in the router. It advances fake timers while the probe runs, expects no error and an unmatched result whose reason mentions the navigation was ignored, verifies the URL remains /users/8, and restores real timers even if an assertion fails.
  • observed — Modified behavior in packages/devtools/src/router-actions.ts: probe now starts the 10-second timeout and assigns the target ID before navigating, using the current ID if negative or the next ID otherwise. Previously, it assigned the ID and started the timeout after navigateByUrl returned. The probe still ignores rejection of the navigation promise.


Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: reporting that probing the current URL was skipped.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.



✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
bb3f361 2026-10-11T02:02:36.462Z View logs ↗
  • Build: Failed ❌

View logs ↗
9ec73d8 2026-10-10T21:50:52.563Z View logs ↗

@erkamyaman
erkamyaman merged commit 0d0346c into main Oct 11, 2026
6 of 7 checks passed
@erkamyaman
erkamyaman deleted the fix/router-probe-current-url branch October 11, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: package The ng-devtools package (packages/ng-devtools) no-docs This pull request needs no docs change (the reason is in the description)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant