fix(lazyLoad): abort URL-sourced transition when lazy loaded states do not match the URL#1
Closed
simshanith wants to merge 1 commit into
Closed
fix(lazyLoad): abort URL-sourced transition when lazy loaded states do not match the URL#1simshanith wants to merge 1 commit into
simshanith wants to merge 1 commit into
Conversation
…o not match the URL When a URL matches a future state's prefix but nothing in the lazy loaded module matches the full URL, retryTransition() delegates to urlService.sync() but returned undefined, letting the original transition resume and activate the deregistered .** placeholder, superseding the otherwise() transition started by sync(). Return false after sync() to abort the original transition so the sync()-initiated transition (e.g. the otherwise() rule) can complete. Closes ui-router#850
dbc4d63 to
7744eae
Compare
Owner
Author
|
closing; ui-router#851 is the upstream |
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.
Summary
Fix for ui-router#850: when a URL matches a future state's prefix but nothing in the lazy-loaded module matches the full URL, the original URL-sourced transition resumed after
urlService.sync()and activated the already-deregistered.**placeholder, superseding theotherwise()transition started bysync().Fix
In
retryTransition()(src/hooks/lazyLoad.ts), abort the original transition by returningfalseafter delegating tosync(). The STATE-rule branch above already avoidssync()precisely because of this supersede hazard; this closes the same hazard in the fall-through branch.Downstream impact
The changed line is only reachable when a URL-sourced transition enters a
lazyLoadstate and, after a successful load, no registered state matches the URL. Successful lazy loads take the STATE-redirect branch; programmatic ($state.go) retries take the non-URL branch — both unchanged.In the affected (previously broken) case:
otherwise()rule (e.g. sample-app-angularjs): deep links now activate the otherwise rule instead of a blank, deregistered placeholder.stateRegistry.get()no longer knows about (which broke subsequent relative navigation / active-state checks).ABORTEDrejections return beforedefaultErrorHandleris invoked (stateService.ts), thetransitionTopromise is already silenced, andurlRouter.update()on abort is gated onisLatest(false here), so the URL doesn't flap. GlobalonErrorhooks observe oneABORTEDtransition where they previously observed a spuriousonSuccess.Tests
Two regression tests in
test/lazyLoadSpec.ts(both fail without the fix, verified):.**future state but matches nothing in the loaded module now activates theotherwise()rule's stateRejectType.ABORTEDFull suite: 587/590 pass (3 pre-existing skips), same as master baseline.
Alternative considered
A stricter variant (#2) aborts only when the original target is no longer registered. In practice they behave identically: reaching the fall-through implies the placeholder's URL rule no longer matched, i.e. it was deregistered. The unconditional abort is simpler and lets whatever
sync()decides win consistently.Closes ui-router#850