question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compiling ivy with aot leads to "ERROR in Maximum call stack size exceeded"

See original GitHub issue

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes and no. Version 8 and 9 without ivy work just fine. However ivy has problems with aot.

Description

After updating existing Angular project from version 8 to 9, compilation with ivy and aot leads to “ERROR in Maximum call stack size exceeded”. Non-ivy compilation works fine with or without aot with all optimization options. Also ivy WITHOUT aot works fine regardless of optimization options.

After much work I have isolated the problem to a module containing a highly mutually interdependent classes. More specifically if any class is imported from that module aot compilation crashes.

🔬 Minimal Reproduction

I have separated the troublesome module from the larger project and created a minimal test bench and can share it via github private repo on request.

🔥 Exception or Error


ERROR in Maximum call stack size exceeded

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.1.0
Node: 12.16.1
OS: win32 x64

Angular: 9.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.0
@angular-devkit/build-angular     0.901.0
@angular-devkit/build-optimizer   0.901.0
@angular-devkit/build-webpack     0.901.0
@angular-devkit/core              9.1.0
@angular-devkit/schematics        9.1.0
@ngtools/webpack                  9.1.0
@schematics/angular               9.1.0
@schematics/update                0.901.0
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, Apr 8, 2020

@SPKorhonen - the problem is in your code. The Angular compiler is trying to statically analyse the code and it gets to this method:

static getBaseFreqMHz(p_Gamma: number, p_FieldStrength: number) {
  return SpinShift.getBaseFreqMHz(p_Gamma, p_FieldStrength);
}

which is infinitely recursive. And so the static analyzer is unable to stop - leading to a call stack overflow.

1reaction
SPKorhonencommented, Apr 8, 2020

Thanks for very fast reply.

Unfortunately the nightly did not resolve the problem.

I have send invitations for the aot-crash repo.

FYI: the problematic module is aot-crash/src/app/spin/spinsystem.ts which is used within aot-crash/src/app/crash.service.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Maximum call stack size exceeded" in Angular 9 ng build
I had circular dependencies caused by my IDE automatically adding references to modules and components before I changed some things around. Use ...
Read more >
Angular Aot Build Error Maximum Call Stack Size Exceeded ...
This error is almost always means you have a problem with recursion in JavaScript code as there isn't any other way in JavaScript...
Read more >
maximum call stack size exceeded angular - You.com
1.This error occur when there is an infinite loop. As you have mentioned that the page loads when app-heroes is commented, this might...
Read more >
angular/angular-cli - Gitter
Hello Iam gettingE RROR in Maximum call stack size exceeded. @angular/cli: 1.0.0-beta.31 node: 7.4.0 os: win32 x64. I saw a few hints about...
Read more >
Angular Ivy
If you opt-out of bundling dependencies you will need to run the standalone Angular compatibility compiler ( ngcc ). This is needed because...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found