Skip to content

fix(ivy): scan simple children routes with no infinite recursion - #28370

Closed
cexbrayat wants to merge 2 commits into
angular:masterfrom
cexbrayat:fix/ivy-lazy-routes
Closed

cexbrayat wants to merge 2 commits into
angular:masterfrom
cexbrayat:fix/ivy-lazy-routes

Conversation

@cexbrayat

Copy link
Copy Markdown
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Now that PR #27697 landed for lazy route analysis in ngtsc, a simple route config with:

{ path: '', children: [
  { path: 'foo', component: FooComp }
] }

results in a ERROR in Maximum call stack size exceeded when running ngtsc.

What is the new behavior?

This PR fixes the infinite recursion introduced and adds a simple test that demonstrates it
(without the fix, the test itself triggers an infinite loop).

Does this PR introduce a breaking change?

  • Yes
  • No

@cexbrayat
cexbrayat requested a review from a team January 25, 2019 16:16
const children = route.get('children');
if (Array.isArray(children)) {
recursivelyScanRoutes(routes);
recursivelyScanRoutes(children);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL! Good catch.

expect(routes[0].referencedModule.filePath.endsWith('/lazy.ts')).toBe(true);
});

it('should detect no lazy routes for simple children routes', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that this got stuck in an infinite recursion previously?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly

@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer effort1: hours freq2: medium area: core Issues related to the framework runtime target: major This PR is targeted for the next major release comp: ivy risk: medium labels Jan 25, 2019
@ngbot ngbot Bot added this to the needsTriage milestone Jan 25, 2019
imports: [
RouterModule.forRoot([
{path: '', children: [
{path: 'foo', component: FooCmp}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is enough to show that we are not stuck in infinite recursion, but having some actual lazy-loaded children to show that they are correctly picked up, would be a good idea imo 😉

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like:

RouterModule.forRoot([
      {path: '', children: [
        {path: 'foo', component: FooCmp},
        {path: 'lazy', loadChildren: './lazy#LazyModule'}
      ]},
    ]),

?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly 😃

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkalpak Alright, I pushed a fixup commit

@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 28, 2019
@gkalpak

gkalpak commented Jan 28, 2019

Copy link
Copy Markdown
Member

merge-assistance: Needs g3sync.

@jasonaden

Copy link
Copy Markdown
Contributor

Error running presubmit. Need to debug.

@jasonaden

Copy link
Copy Markdown
Contributor

Presubmit

@angular-automatic-lock-bot

Copy link
Copy Markdown

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 Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes effort1: hours freq2: medium merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note risk: medium target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants