angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Maximum call stack size exceeded after updating `@angular/compiler-cli`

Open michalSolarz opened this issue 6 years ago β€’ 30 comments

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

Yes, the previous version in which this bug was not present was: 9.0.2

Description

After updating `@angular/compiler-cli 9.0.3` during ng serve I receive following error: `ERROR in Maximum call stack size exceeded`

πŸ”¬ Minimal Reproduction

πŸ”₯ Exception or Error

ERROR in Maximum call stack size exceeded

🌍 Your Environment

ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.0.3
Node: 12.13.1
OS: linux x64

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

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.3
@angular-devkit/build-angular     0.900.3
@angular-devkit/build-optimizer   0.900.3
@angular-devkit/build-webpack     0.900.3
@angular-devkit/core              9.0.3
@angular-devkit/schematics        9.0.3
@angular/cdk                      9.1.0
@angular/compiler                 9.0.2
@angular/material                 9.1.0
@ngtools/webpack                  9.0.3
@schematics/angular               9.0.3
@schematics/update                0.900.3
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?

michalSolarz avatar Feb 27 '20 14:02 michalSolarz

I've just created a new site from scratch on angular 9, and got this error, installed terser@latest, error gone, so it is confirmed on my side that the terser library required by server-platform is the buggy element.

ayyash avatar Mar 24 '20 17:03 ayyash

I got this error as soon as I created a pipe in my project. The app is using angular 9.0.4. When I removed implement PipeTransform from the pipe, the error disappeared but now lint is complaining i should implement the interface. But luckily I no longer need the pipe, so I will delete it and no prob. I was also using domSanitizer in the tranform method.

chikakow avatar Mar 26 '20 23:03 chikakow

I had to reorganize some of my index.ts which were exposed in public-api.ts of my lib.

safebees avatar Apr 06 '20 09:04 safebees

I had this error as well but in slightly different circumstances:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.1.0
Node: 10.19.0
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-ng-packagr   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
ng-packagr                         9.0.0
rxjs                               6.5.5
typescript                         3.7.5
webpack                            4.39.2

I was trying to build a prod library, this has to have ivy turned off. A library build with Ivy was fine. I tried all the various fixes listed here but nothing helped.

In the end I discovered that barrel files broke it for me.

This code worked fine:

// public-api.ts
export * from './my-module.module';
export * from './constants/constants';

(constants just exports 2 strings)

This code fails:

// public-api.ts
export * from './my-module.module';
export * from './constants';

(exports an index.ts file that just exports * from constants)

The workaround I found was to directly export every file in public.api and avoid barrels. The npm lib barrelsby helped a lot with this:

barrelsby -e .spec.ts -D true -l top -n public.api

Roaders avatar Apr 11 '20 10:04 Roaders

The possible reasons for the issues are

  1. Infinite recursion: recursive function call without a termination condition
  2. Importing Parent Module in childe module
  3. Mistakenly Self importing a module (see example)
@NgModule({
  imports: [
    TestModule
  ],
  declarations: [],
  exports: []
})
export class TestModule { }

kalimulhaq avatar Apr 22 '20 07:04 kalimulhaq

The answer of @kalimulhaq helps me, in my case, I was exporting my own module :/

  declarations: [
    MyComponent
  ],
  imports: [
    CommonModule
  ],
  exports: [
    MyModule,    <---- My problem    
  ]
})
export class MyModule { }

jdmaldonado avatar Apr 28 '20 11:04 jdmaldonado

Another possible reason is something like this:

export function max(values) {
  return max(_.compact(values)); // Calling itself instead of _.max
}

sorin-davidoi avatar Apr 29 '20 08:04 sorin-davidoi

Seta no angular.json "aot": false,

heliogsantos avatar May 16 '20 01:05 heliogsantos

Seta no angular.json "aot": false,

Funcionou para mim. Obrigado!

walvesribeiro avatar May 26 '20 22:05 walvesribeiro

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.