Repository navigation
ERROR in Maximum call stack size exceeded : Feature module circular dependency #6309
Description
Bug Report or Feature Request (mark with an x)
- [X] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.0.0-rc.2
node: 6.10.0
os: linux x64
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/router: 3.4.10
@angular/cli: 1.0.0-rc.2
@angular/compiler-cli: 2.4.10
Repro steps.
STEPS TO REPRODUCE
See git repo
https://github.com/vaibhavbparikh/circular-routes
The log given by the failure.
** NG Live Development Server is running on http://localhost:4200 **
Hash: f669143e24ec08ff9586
Time: 23223ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 232 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 332 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 304 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.64 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR in Maximum call stack size exceeded
webpack: Failed to compile.
However when I do any changes in file and save it again, angular-cli compiles it again and it runs fine then.
Desired functionality.
This behaviour shall not create cyclic dependency, there should be mechanism to detect this and break.
Either it shall not compile at all or it shall not throw error at first compile.
** USE CASE **
I have 3 Feature modules in the application. Each Feature modules contains 3 or more sub feature modules with their own components and specially routes with router module.
Now consider below scenario.
I have modules as below.
- Feature 1
- Feature1Sub Feature 1
- Feature1Sub Feature 2
- Feature 2
- Feature2Sub Feature 1
- Feature2Sub Feature 2
- Feature 3
- Feature3Sub Feature 1
- Feature3Sub Feature 2
Now Consider below flow.
I am loading Feature 1 -> Feature1Sub Feature 1. I want to load Feature2Sub Feature 1 directly from Feature1Sub Feature 1. Without loading whole Feature 2 module. Also, I need to maintain navigation flow with back button.
So I will need to write routes and load that module with loadchildren feature in module of Feature1Sub Feature 1.
Same way I want to load Feature1Sub Feature 1 directly from Feature2SubFeature 1 without loading whole Feature 2 module. So again I will need to write routes in Feature1Sub Feature 1 module.
As a complex and large application, there might be need to create flow where two or more modules needs each other with routing.
Activity
vaibhavbparikh commentedon May 14, 2017
#5427
This is similar issue but it's scenario is different.
vaibhavbparikh commentedon May 15, 2017
@sumitarora any tentative timeline for this issue?
mikeumus commentedon May 25, 2017
I've been getting this error too and in the browser for angular/cli@1.0.3-1.0.5
vaibhavbparikh commentedon May 26, 2017
@mikeumus Can you share more details about how you are getting this error?
mikeumus commentedon May 27, 2017
Windows 7 Pro
Angular 4.1.0
Angular CLI 1.0.5
The project still runs fine in Angular 2.4 / CLI 1.0.0-rc.2
Max exceed error in browser with dev build
ng buildMax exceed in cli terminal with prod/AoT build.
ricardotorre commentedon Jun 5, 2017
I am also having these problem with latest versions, I also have a module referencing it self:
Windows 10 Pro (Creators Update)
Node 6.10.3
Npm 3.10.10
Angular 4.1.3
Angular CLI 1.1.0
The weird thing is that when I use watch mode and save a file it builds successfully
feat(@angular/cli): add circular dependency detection
feat(@angular/cli): add circular dependency detection
feat(@angular/cli): add circular dependency detection
feat(@angular/cli): add circular dependency detection
9 remaining items
fearless23 commentedon Oct 30, 2017
@vaibhavbparikh @filipesilva The lazy loaded or feature module must have a route declared.
app.routing.ts --> path="lazy" loadchildren="../lazy/lazy.module#LazyModule"
inside Lazy Module --> path=' ' component="lazyParentComponent"
path='child' loadChildren='../child/child.module#childModule
If we skip routing in lazy module or don`t give path to when lazy module is loaded it gives error
AnthonyNahas commentedon Nov 9, 2017
the
ERROR in Maximum call stack size exceededhappens actually when you have some infinite loop in your code.I had the same problem with my routes.
Scenario:
i have a lazyloadmodule that does not bind any component to the view -->
##Before: in HomeModule -->
##After: (Solution) in HomeModule -->
i hope that could helps someone
ricardotorre commentedon Nov 10, 2017
in angular5 and cli 1.5 this is working without problems!
And just a quick note, self referencing routes are a valid implementation when doing unlimited depth routes like:
/root/subroute-type1/subroute-type1/.../subroute-typeN/
christofferskog commentedon Nov 15, 2017
Still happening on 1.5.0, I've got a
PageModulewhich reference itself in it's routing. It works if I remove the circular dependency, start the app and then add it again. But not if I stop the server and start it again with the circular dependency already there. How can I solve this?For reference, I have this router module:
Which is then imported into
PageModule:ricardotorre commentedon Nov 15, 2017
are you using Angular 5? It works for me (I have a self reference too) since I upgraded to Angular 5.0.1 (I upgraded it alongside with CLI to 1.5.0 and Material to 5.0.0-rc0)
I believe this is due to the new compile-cli from angular
feat(@angular/cli): add circular dependency detection
vugar005 commentedon Sep 4, 2018
In my situation it was because feature module was not importing its child routes.
This solved my issue.
chaitanyagawande commentedon Nov 7, 2018
In my situation, this issue occurred because same name of two components.
appify-ArsalanJaved commentedon Jan 29, 2019
In my case i'ám using reactive forms and formControlName and ID was same that's why function oninput was calling in loop.
vigneshTheDev commentedon Apr 28, 2019
In my case, the changes were not reflecting in the browser. I had to save lazyModule and lazyRoutingModule again :|
angular-automatic-lock-bot commentedon Sep 9, 2019
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.
feat(@angular/cli): add circular dependency detection