Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router): support lazy loading for empty path named outlets #38379

Closed
wants to merge 3 commits into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Aug 7, 2020

In general, the router only matches and loads a single Route config tree. However,
named outlets with empty paths are a special case where the router can
and should actually match two different Routes and ensure that the
modules are loaded for each match.

This change updates the "ApplyRedirects" stage to ensure that named
outlets with empty paths finish loading their configs before proceeding
to the next stage in the routing pipe. This is necessary because if the
named outlet has loadChildren but the associated lazy config is not loaded
before following stages attempt to match and activate relevant Routes,
an error will occur.

fixes #12842

global presubmit - Will want to do another rerun as I made a tiny change since then to pass the test "should work work with redirects when other outlet comes before the one being activated"

@atscott atscott requested a review from alxhub August 7, 2020 17:57
@atscott atscott added area: router action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release router: aux routes router: lazy loading type: bug/fix labels Aug 7, 2020
@ngbot ngbot bot modified the milestone: needsTriage Aug 7, 2020
@atscott atscott force-pushed the loadOtherOutlets branch 2 times, most recently from 71a6595 to ac00cdd Compare August 10, 2020 20:29
@atscott atscott added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Aug 10, 2020
@atscott
Copy link
Contributor Author

atscott commented Aug 11, 2020

new global presubmit

packages/router/src/apply_redirects.ts Outdated Show resolved Hide resolved
@atscott atscott force-pushed the loadOtherOutlets branch 3 times, most recently from 196bf2f to fe12333 Compare August 17, 2020 19:31
subratpalhar92 added a commit to SUBRATPALHAR-ALL-JAVASCRIPT/angular that referenced this pull request Aug 31, 2020
subratpalhar92 pushed a commit to SUBRATPALHAR-ALL-JAVASCRIPT/angular that referenced this pull request Aug 31, 2020
…ar#38379)

In general, the router only matches and loads a single Route config tree. However,
named outlets with empty paths are a special case where the router can
and should actually match two different `Route`s and ensure that the
modules are loaded for each match.

This change updates the "ApplyRedirects" stage to ensure that named
outlets with empty paths finish loading their configs before proceeding
to the next stage in the routing pipe. This is necessary because if the
named outlet has `loadChildren` but the associated lazy config is not loaded
before following stages attempt to match and activate relevant `Route`s,
an error will occur.

fixes angular#12842

PR Close angular#38379
subratpalhar92 pushed a commit to SUBRATPALHAR-ALL-JAVASCRIPT/angular that referenced this pull request Aug 31, 2020
atscott and others added 2 commits September 1, 2020 12:36
In general, the router only matches and loads a single Route config tree. However,
named outlets with empty paths are a special case where the router can
and should actually match two different `Route`s and ensure that the
modules are loaded for each match.

This change updates the "ApplyRedirects" stage to ensure that named
outlets with empty paths finish loading their configs before proceeding
to the next stage in the routing pipe. This is necessary because if the
named outlet has `loadChildren` but the associated lazy config is not loaded
before following stages attempt to match and activate relevant `Route`s,
an error will occur.

fixes angular#12842
@atscott atscott force-pushed the loadOtherOutlets branch 2 times, most recently from 1333aee to 0a52656 Compare September 1, 2020 19:57
@atscott atscott requested a review from alxhub September 1, 2020 20:37
@atscott
Copy link
Contributor Author

atscott commented Sep 1, 2020

@alxhub PTAL

The internal failure was due to a stack overflow caused by the switchMap approach (test added that failed in the previous version). The new approach is to

  1. separate the Routes by their outlet names
  2. run the exact same algorithm as before, but ignoring errors from expanding routes of outlets that differ from the one being activated (I wish the git diff was showing this better).
  3. Wait for each of the observables-by-outlet to complete and return only the one for the outlet being activated

This has the added benefit of loading all matched outlets concurrently. Additionally, the concatAll, first() is able to exit the processing as soon as a match is found rather than proceed with the switchMaps and produce no-ops for following routes of the same outlet like the old algorithm would.

global presubmit

@atscott atscott removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews state: blocked labels Sep 1, 2020
@atscott atscott force-pushed the loadOtherOutlets branch 4 times, most recently from c9e6957 to a46f081 Compare September 2, 2020 15:21
packages/router/src/apply_redirects.ts Outdated Show resolved Hide resolved
packages/router/src/apply_redirects.ts Outdated Show resolved Hide resolved
@atscott atscott added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit labels Sep 3, 2020
@ngbot
Copy link

ngbot bot commented Sep 3, 2020

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google3" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ar#38379)

In general, the router only matches and loads a single Route config tree. However,
named outlets with empty paths are a special case where the router can
and should actually match two different `Route`s and ensure that the
modules are loaded for each match.

This change updates the "ApplyRedirects" stage to ensure that named
outlets with empty paths finish loading their configs before proceeding
to the next stage in the routing pipe. This is necessary because if the
named outlet has `loadChildren` but the associated lazy config is not loaded
before following stages attempt to match and activate relevant `Route`s,
an error will occur.

fixes angular#12842

PR Close angular#38379
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
@atscott atscott closed this in 926ffcd Sep 8, 2020
@danylobilokha
Copy link

hi guys, any update on that? Stuck with this issue and need this PR

@atscott
Copy link
Contributor Author

atscott commented Sep 19, 2020

@danylobilokha it’s available in the v11 release, currently 11.0.0-next.2

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lazy loaded module in named outlet throws error
9 participants