Updating a collection in server callback error

        Downloader.on("progress", function(progress) {
    
               console.log(progress);
       
                Progress.update({'videoId': videoId},
                {$set: {progress: progress}},
                {multi: true});
        });

The error I am getting is: Metoer code must always run within a Fiber. Try wrapping callbacks that you pass to non meteor libraries with Meteor.bindEnviroment

It works if I remove the progress.update.

I have tried

          Meteor.bindEnvironment((err, res) => {
            console.log(progress);
          
                Progress.update({'videoId': videoId},
                {$set: {progress: progress}},
                {multi: true});
            });

But still no good

Have you tried something like:

Downloader.on('progress', Meteor.bindEnvironment((progress) => {
  ... your update code ...
}));

If that doesn’t help, can you let us know which Downloader package/library you’re using?

1 Like

Thanks that seemed to do it!