Repository navigation
fix(router): prevent stale onmatch rejections from redirecting - #3081
Open
sergioperezcheco wants to merge 1 commit into
Open
sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
Preserve the latest navigation when an obsolete resolver rejects, while keeping its error visible. Assisted-by: Hermes Agent Signed-off-by: sergioperezcheco <checo520@outlook.com>
This branch has not been deployed
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.
Description
Guard a rejected
onmatchwith the same resolver identity check already used for successful resolutions. A stale rejection is still logged, but cannot redirect a newer navigation to the fallback route. Rejections belonging to the current resolver retain their existing fallback behavior.Motivation and Context
Start an asynchronous
/slowroute, navigate to/next, then reject the original promise. Currently the rejection callsroute.set(fallbackRoute)even though/nexthas already resolved. It can also cancel a pending newer resolver or aroute.setwhose matching callback has not run yet.This extends the existing latest-navigation-wins behavior discussed in #1461 and implemented for successful resolutions. The check uses resolver identity rather than the pathname, so reloading the same route is handled correctly. Error visibility from #2531 is preserved. This does not change fallback-route rejection behavior or attempt to redesign router lifecycle cancellation.
How Has This Been Tested?
On macOS, Node.js 22.22.3 and headless Chromium 151.0.7922.34:
npm testcommand against both versions: the original fails only the 11 new regression assertions; the fixed version passes all 1,132,071 assertions.npm run build. Exercised the resulting full and minified bundles through the publicm.routeAPI in Chromium, checking rendered content, URL, resolved route, and retained error logging. The stale-rejection reproduction fails before the fix and passes after it. Additional browser controls cover pending navigation, immediate navigation, current fallback, and stale success.git diff --checksuccessfully.One earlier full-suite run exceeded an existing 200 ms timeout in a different router test; unchanged sequential reruns, including the final independent verification, passed. Other Node versions, operating systems, Firefox and WebKit were not tested locally.
AI assistance was used to develop this change and its tests; the patch and regression behavior were independently reviewed and exercised by a second automated pass.
Types of changes
Checklist