[Resolved] RangeError: Maximum call stack size exceeded Unhandled Promise Rejection Warning


#1

Hello,

(node:11557) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
at Array.forEach (<anonymous>)
 at Object.EJSON.clone (packages/ejson/ejson.js:594:18)
at packages/ejson/ejson.js:595:22
at Array.forEach (<anonymous>)
at Object.EJSON.clone (packages/ejson/ejson.js:594:18)
at packages/ejson/ejson.js:595:22
at Array.forEach (<anonymous>)
 at Object.EJSON.clone (packages/ejson/ejson.js:594:18)
 at packages/ejson/ejson.js:595:22
 at Array.forEach (<anonymous>)
(node:11557) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)

i have this error when i’m debugging i see that it was from this code lines
PS: if i comment the find i don’t see the error

 try {
            console.log("useruseruser1", user);

            var searchOptions = {};

            if (!user.role || user.role == "" || user.role == "all") {
                searchOptions["roles.app"] = {
                    $ne: "super-admin"
                }
            } else {
            searchOptions["roles.app"] = user.role
            }

            if (user.keyword && user.keyword != "") {
                searchOptions.$or = [{
                        "profile.firstName": {
                            $regex: user.keyword,
                            $options: 'i'
                        }
                    },
                    {
                        "username": {
                            $regex: user.keyword,
                            $options: 'i'
                        }
                    },
                    {
                        "profile.lastName": {
                            $regex: user.keyword,
                            $options: 'i'
                        }
                    },
                    {
                        "profile.bio": {
                            $regex: user.keyword,
                            $options: 'i'
                        }
                    },
                    {
                        "emails.address": {
                            $regex: user.keyword,
                            $options: 'i'
                        }
                    },
                    {
                        "profile.id": {
                            $regex: user.keyword,
                            $options: 'i'
                        }
                    }
                ];
            }
            searchOptions["profile.removed"] = false
            console.log('searchOptionssearchOptions', searchOptions);
        
            return Meteor.users.find(searchOptions, {
                fields: {
                    'username': 1,
                    'emails': 1,
                    'profile': 1,
                    'roles': 1
                }, // Ending Row
                sort: {
                    "profile.createdAt": -1 //Sort by Date Added DESC
                }
            })
        } catch (error) {
            console.log("GetAllUsers Error", error);
            if (error.reason) {
                throw new Meteor.Error(203, error.reason);
            } else {
                throw new Meteor.Error(203, error);
            }
        }

Meteor doesn't logout
#2

no answer ? o_O help please


#3

Can you show the lines of code that calls the function? Specifically, where you use .forEach in the resulting cursor


#4

(packages/ejson/ejson.js:594:18)

it is a meteor builtin package


#5

How many records are you returning?


#6

250 record and i did a limit of 20 but the same error


#7

i did new empty DB same problem


#8

I’m not familiar with the package so I cannot help further. The last idea I have is to return the data as array by calling fetch() in find() and not return the cursor.


#9

yes i changed it to .fetch and it works thanks alot

i think the validate mthods didn’t return cursors that the problem