How to run heavy task in background in Meteor

I have a method which returns some configurations.

But inside that I am running some heavy queries which takes lots of times e.g:


Now these 2 queries takes 5 to 6 seconds, I need these queries to run in background.

Is there any way in Meteorjs to run heavy tasks in background like we do in nodejs with worker threads?

Have a look at this discussion about using web workers with Meteor.

@allerion The issue I am facing is that in worker.js I get error Meteor is not defined

As mentioned in the other thread, it’s your queries that are the problem. I can’t imagine that you need to run them without any condition, so avoid updating docs that don’t need to be updated in the first place.