balderdashy / waterline-cursor

Association/subquery helper
1 stars 11 forks source link

The forEach loop in Buffer.add function throws " Maximum call stack size exceeded" error #3

Closed ArVan closed 9 years ago

ArVan commented 9 years ago

I have a sails-mongo search query with populate and sorting. In certain conditions it must return about 40K entities. Query looks like this:

Property.find({id: matchedPropertyIds})
                    .populate('realtor', {status: RowStatus.active})
                    .sort(sortOpt)
                    .exec(function(err, matchedProperties) {
                   });

But the app crashes with the error:

/srv/nodejs/skupit/node_modules/sails-mongo/node_modules/waterline-cursor/cursor/buffer.js:48
 values.forEach(function(val) {
        ^
RangeError: Maximum call stack size exceeded
mikermcneil commented 9 years ago

@ArVan awesome, thanks for the heads up. If you (or anyone else reading this) has a moment to write a failing test, that would help us out a lot. I've seen you around for a while- if you'd like to get more involved with the project, please let me know (tweet @mikermcneil)

bryandent commented 9 years ago

We are getting this error as well. Our data set is rather small, 12K objects.

devinivy commented 9 years ago

From @ilya-khaustov on #2 , which seems to be the same issue:

More of this bug here - balderdashy/waterline#733

There is synchronous call in buildChildBuffers function in the file populateBuffers.js, line 68. This problem is widely covered here - caolan/async#588. I guess it would be enough to change line 68 from nextParent() to async.setImmediate(nextParent).

wancharle commented 9 years ago

I have this error as well. My data set is rather small, 4k objects.
The solution from @ilya-khaustov on #2 has solve the problem in my project.

devinivy commented 9 years ago

PR #5 posted implementing @ilya-khaustov's fix.