Meteor methods - Promise on server side

assuming I’m having the following Meteor method:


'test': function() {

    return new Promise((resolve) => {
       setTimeout(() => {resolve(true);},10000);

server/test.js'test',(err,res) => {console.log(res)});

The problem is, that the callback is called immediately without waiting for the Promise. As response I only get a {}.If I do the same on client side

client/test.js'test',(err,res) => {console.log(res)});

everything is working fine. Why does a Promise method don’t work on server side? I’ve already tried, but this one is also not working (I guess it’s client side only if I take a look into the package.js).

Is there any workaround or package? Currently I have to wrap our async function with Meteor.wrapAsync but it would be cool if I could remove it and replace it with some ES6 stuff :slight_smile:



You should have a look here

1 Like

@n1s Yeah, I’ve read this great article already. The problem is that it shows the typical client<->server case where Promises work fine. In my case, I do a server<->server method call - there I get an empty response within the callback.

@robfallows any idea why server<->server doesn’t work (example above)?

@XTA you can try const promise = someFunctionThatReturnsAPromise(); return promise.await(); similar to what i posted here: Nightmarejs inside meteor Can't return method result

Let me know if it works for you.


You can use the synchronous version of and use Promise.await(...) to make your promise synchronous


@tomsp Thank you man, this way it works :slight_smile:

1 Like

I discovered this behaviour a while ago, but didn’t make a repro. I’m going to do that today and raise an issue if needed.

EDIT: Issue raised: