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

RangeError: Maximum call stack size exceeded #1

Open
jmls opened this issue Feb 10, 2014 · 11 comments
Open

RangeError: Maximum call stack size exceeded #1

jmls opened this issue Feb 10, 2014 · 11 comments

Comments

@jmls
Copy link

jmls commented Feb 10, 2014

I'm getting this error , with the following information :

node_modules/electrolyte/lib/component.js:9
Component.prototype.create = function(container) {

this may be happening because I have two components that need each other: so

Component A requires Component B, and
Component B requires Component A

how would I get around this problem ?

@jaredhanson
Copy link
Owner

I'm planning on adding a check for circular dependencies and throwing an error before the stack size is exceeded.

I don't know of a good workaround to the circular dependency problem. As a general rule, that's a sign that the two components need to be broken down (say add C that both A and B depend on, but C itself doesn't depend on either). If that's not possible, could you describe the relation of the components a bit more so I can understand it better and think on it?

@Kroid
Copy link

Kroid commented Sep 7, 2014

@BrunoBernardino
Copy link

I'm wondering in a situation where you've got a mongoose model, Blog, that has Posts. Post, has a Blog.

How can I avoid that (right now, it's just including each model via normal require — which works but misses the point of DI and better testing)?

I'd love to have electrolyte support that.

@abloom
Copy link

abloom commented Feb 20, 2015

@BrunoBernardino I had the same issue with Bookshelf. I ended up defining each model in their own file using electrolyte, and then having a 3rd file to attach the associations, sort of the A/B and C pattern @jaredhanson mentioned above.

It's not ideal, but it works and the 3rd file ends up being the entry point for all my models.

@muttli
Copy link

muttli commented Jun 8, 2015

@jaredhanson any updates on this issue? It's kind of critical in my opinion that this gets fixed.

@aegyed91
Copy link

+1

3 similar comments
@aimuzov
Copy link

aimuzov commented Jan 4, 2016

👍

@ORusak
Copy link

ORusak commented Jul 18, 2016

+1

@anotheri
Copy link

anotheri commented Nov 8, 2016

👍

@kingjerod
Copy link

kingjerod commented Dec 20, 2016

I'm also running into this problem with SequelizeJS when doing a relationship with A.hasMany(B) and B.belongsTo(A).

Edit: I was able to get around this for Sequelize by defining my models in separate files (which I was doing anyways), and then injecting them into a third class which creates the relationships. Not as clean as I'd like, but it will do for now.

@angelwithaneye
Copy link

Still an issue in latest version 0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests