buunguyen / mongoose-deep-populate

Mongoose plugin to enable deep population of nested models ⛺
MIT License
469 stars 44 forks source link

Maximum call stack size exceeded? #36

Closed alemonmk closed 8 years ago

alemonmk commented 8 years ago

Hi, I encountered some really weird problem:

RangeError: Maximum call stack size exceeded
      at isFinite (native)
      at Buffer.write (buffer.js:559:14)
      at serializeObject (node_modules\mongoose\node_modules\mongodb-core\node_modules\bson\lib\bson\parser\serializer.js:276:37)
      at serializeInto (node_modules\mongoose\node_modules\mongodb-core\node_modules\bson\lib\bson\parser\serializer.js:551:17)
      at serializeObject (node_modules\mongoose\node_modules\mongodb-core\node_modules\bson\lib\bson\parser\serializer.js:280:18)
      at serializeInto (node_modules\mongoose\node_modules\mongodb-core\node_modules\bson\lib\bson\parser\serializer.js:705:17)
      at serializeObject (node_modules\mongoose\node_modules\mongodb-core\node_modules\bson\lib\bson\parser\serializer.js:280:18)
      ...

Schema definitions: https://github.com/alemonmk/bonappetit-nodejsserver/blob/develop/models/mongo_models.js

Access code: https://github.com/alemonmk/bonappetit-nodejsserver/blob/develop/routes/user.js#L120

Problem still occurs even I shorten the path to only cart.content, and it doesn't matter whether cart.content has data or not.

Using koa@1, mongoose@4.3.5, mongoose-deep-populate@2.0.3.

What did I miss?

buunguyen commented 8 years ago

Please post fully working code or a failed test.

alemonmk commented 8 years ago

Okay, I changed the original post.

buunguyen commented 8 years ago

Please post a single piece of code that: 1. can be copied and pasted to my editor, 2. can be executed immediately without change and 3. it throws the error in question. I don't have time to debug your app.

alemonmk commented 8 years ago

Fine...please have a look at this test: https://gist.github.com/alemonmk/a4289640798d31afe1eb

It seems that I was misled by README->Perform population->On an instance of Post as I am not sure what the instance of Post is and use the retrieved document to do population.

But even I use the populate on Query way, the error in question is still there, I don't know where to look as the stack trace are truncated, and I'm unable to reproduce it out of my app :/

And I do the same thing in REPL with my real data and it works!

Forgot to mention I use node@5.4 with --harmony flag.

alemonmk commented 8 years ago

I'm sorry for bringing up a non-issue, I've confirmed that the problem is not about your plugin.