Meteor: Uncaught Error: Must be attached (delete function)

Meteor: Uncaught Error: Must be attached (delete function)

每次我在 Meteor 应用程序中删除项目(列表)时,控制台都会出现错误。 控制台中的错误是:

domrange.js:337 Uncaught Error: Must be attached

这是函数,我不明白这个错误是从哪里来的:

Lists.js

Meteor.methods({
   'lists.remove'(listId) {
       check(listId, String);

       const list = Lists.findOne(listId);
       if (list.owner !== this.userId) {
           throw new Meteor.Error('not-authorized');
       }
       Tasks.remove({"listId": listId});
       Lists.remove(listId);
   },

应用程序中一切正常,但您知道此错误可能来自何处吗?

Ps:如果 Blaze 有帮助,我正在使用它

谢谢

看来我找到了添加 Meteor.isServer 或更好的解决方案 if (!this.isSimulation) (@MasterAM 解决方案):

    'lists.remove'(listId) {
        check(listId, String);

        const list = Lists.findOne(listId);
        if (list.owner !== this.userId) {
            throw new Meteor.Error('not-authorized');
        }
        if (!this.isSimulation) {
            Tasks.remove({"listId": listId});
            Lists.remove(listId);
        }
    },

我在@MasterAM 的帮助下编辑了工作代码现在可以工作了!不再有控制台错误。