Meteor:RangeError:超出最大调用堆栈大小

时间:2014-12-10 12:52:43

标签: javascript meteor

我收到以下错误

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.

当我使用meteor方法返回查询结果时。

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

1 个答案:

答案 0 :(得分:8)

您无法从方法返回光标 - 仅EJSON。在您的代码中,resultfind调用的结果,这是一个游标 - 您需要使用findOne或在fetch()之后添加find()返回有问题的文件。

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)