最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Meteor: RangeError: Maximum call stack size exceeded - Stack Overflow

programmeradmin2浏览0评论

I am getting the following error

W20141210-18:14:54.394(5.5)? (STDERR) 
W20141210-18:14:54.395(5.5)? (STDERR) /Users/removed/.meteor/packages/meteor-tool/.1.0.36.1phxfod++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141210-18:14:54.395(5.5)? (STDERR)                       throw(ex);
W20141210-18:14:54.395(5.5)? (STDERR)                             ^
W20141210-18:14:54.396(5.5)? (STDERR) RangeError: Maximum call stack size exceeded
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

When I am using meteor methods to return a query result.

Meteor.methods({
    rquery: function(post){
        console.log(post);
        var result = AdvtColl.find();
        return result;
    }
});

I am getting the following error

W20141210-18:14:54.394(5.5)? (STDERR) 
W20141210-18:14:54.395(5.5)? (STDERR) /Users/removed/.meteor/packages/meteor-tool/.1.0.36.1phxfod++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141210-18:14:54.395(5.5)? (STDERR)                       throw(ex);
W20141210-18:14:54.395(5.5)? (STDERR)                             ^
W20141210-18:14:54.396(5.5)? (STDERR) RangeError: Maximum call stack size exceeded
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

When I am using meteor methods to return a query result.

Meteor.methods({
    rquery: function(post){
        console.log(post);
        var result = AdvtColl.find();
        return result;
    }
});
Share Improve this question asked Dec 10, 2014 at 12:52 rekureku 7639 silver badges17 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 8

You can't return a cursor from a method - only EJSON. In your code, result is the result of a find call, which is a cursor - you need to either use findOne or add fetch() after the find() to return the document(s) in question.

var result = AdvtColl.findOne(); // RETURNS A DOCUMENT

var result = AdvtColl.find().fetch(); // RETURNS AN ARRAY OF DOCS (EVEN IF THERE'S ONLY ONE OF THEM)
发布评论

评论列表(0)

  1. 暂无评论