Error: Unknown id for changed: EgwxtWi8GcsiiwhYT

Hey guys,
I’m getting the error above on the client when I call a Meteor method to clear all user notifications. This is my method:

clearNotifications: function () {
    var date = new Date();
    Meteor._sleepForMs(2000);
 Notifications.update({toUser: this.userId, readAt:{$exists:false}}, {$set: {readAt: date}, multi:true});
}

The Notification object is available on the client side before changing the values, I’ve checked it on the console by Notifications.find().fetch().

Why do I get this error?

//Edit: The error is associated with the observer, if I remove it, everything works fine:

notifications: function () {


    var lastPlay = moment();

    Notifications.find().observe({

        added: function (doc) {

            var myMedia = new Media('application/app/sounds/notification_in.wav', function () {
            });


            if (!doc.hasOwnProperty("readAt") && moment().diff(lastPlay,'seconds') > 5) {
                myMedia.play();
                lastPlay = moment();
            }

        },
        change: function (doc) {
        var myMedia = new Media('application/app/sounds/notification_in.wav', function () {
            });


            if (!doc.hasOwnProperty("readAt") && moment().diff(lastPlay,'seconds') > 5) {
                myMedia.play();
                lastPlay = moment();
            }



        }
    });


}

What is the notifications function? When is it called? I am asking because the only strange thing I see is that you never stop the observer…

Just got it, the observer throwed an exception and then everything else stopped working.

1 Like

I was pulling hair out trying to resolve this error with my custom publication. XTA is completely correct. If anything errors out in your publication code, this error may occur on the server. Check over and debug this code carefully.