Meteor: Uncaught RangeError: Maximum call stack size exceeded

让人想犯罪 __ 提交于 2020-01-05 05:29:09

问题


I am very new to Meteor. I am doing simple app. Here is the problem I have:

Template.newFeedForm.events({
   'submit #new-feed-form'(event) {
       event.preventDefault();

       const target = event.target;
       const text = target.text;

       Meteor.call('feeds.insert', text);

       target.text.value = '';
   }
});

So I have newFeedForm template and in my feeds.js I have

Meteor.methods({
    'feeds.insert'(text){
        check(text, String);
        //check(hashtag, String);

        // Make sure the user is logged in before inserting a task
        if (! this.userId) {
            throw new Meteor.Error('not-authorized');
        }
        console.log(this.userId);

        // Feeds.insert({
        //     text: text,
        //     owner: this.userId,
        //     username: Meteor.users.findOne(this.userId).username,
        //     createdAt: new Date()
        // });
    }
});

I commented out the Feeds.insert here thinking that it causes the problem. Seems it is something different. Whenever Meteor.call is executed I got this:

Uncaught RangeError: Maximum call stack size exceeded
    at Function._.(anonymous function) [as isArguments] (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:1068:30)
    at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:512:25)
    at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
    at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:530:5)
    at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
    at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:530:5)
    at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)

Have no Idea what is happening. Here is my repo that reproduces this error: https://github.com/yerassyl/nurate-meteor


回答1:


Typically, when errors like this occur (especially when dealing with a Meteor Method) it means you are probably not passing the "correct" data (or the data that you thought you were).

Looking at your form handling code, I noticed that you are never obtaining the textarea text data.

const text = target.text;

target.text returns the actual textarea DOM object but what you are really after is the value the object contains. The below code will solve your issue.

const text = target.text.value;


来源:https://stackoverflow.com/questions/42375420/meteor-uncaught-rangeerror-maximum-call-stack-size-exceeded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!