Repository navigation
fix(router): report the skip when probing the current URL - #250
Merged
Merged
Conversation
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.
Contributor
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
5 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The router
probeaction checks whether a URL matches without really navigating. It callsrouter.navigateByUrl(url, { skipLocationChange: true })and then reads the new navigation id intotargetId. Its event handler ignores any event whose id isn'ttargetId.When the probed URL is the one the router is already on (with the default
onSameUrlNavigation: 'ignore'), Angular emitsNavigationSkippedsynchronously insidenavigateByUrl. At that pointtargetIdis 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:
targetIdto the next navigation id before callingnavigateByUrl, keeping-1when the id can't be readHow it was verified
Added a test to
router-features.test.tson the real Router setup. It navigates to/users/8, probes/users/8with fake timers, and expects{ matched: false, reason: /ignored/ }with no timeout error. Onmainit fails withexpected '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:checkpnpm typecheck(includes thengctemplate checks)pnpm test:devtools(all passing)pnpm skills:check(when.claude/changed): not changedno-docs)pnpm extension:buildandextension/uicommitted (whenapp/changed): not changedSummary by CodeRabbit