A function wrapped with wrapAsync never returns


I’m trying to wrap a function from a node package with wrapAsync.

filepicker = new Filepicker('API Key') 
filepickerStatSync = Meteor.wrapAsync(filepicker.stat, filepicker)
result = filepickerStatSyncr(url);

The stat function is below.

Everything seem to work fine… the request call responds with the correct result, the final callback is called, the whole thing executes synchronously / yields correctly as far as I can tell… but the sync call never returns and console.log(‘after’) is never hit.

Filepicker.prototype.stat = function(url, options, callback) {
    callback = callback || function(){};
    if(!options) {
        options = {};
    if(!url) {
        callback(new Error('Error: no url given'));
        method: 'GET',
        url: url+'/metadata?',
        form: {
            size: options.size || true,
            mimetype: options.mimetype || true,
            filename: options.filename || true,
            width: options.width || true,
            height: options.height || true,
            writeable: options.writeable || true,
            md5: options.md5 || true,
            path: options.path || true,
            container: options.container || true,
            security: options.security || {}
    }, function(err, res, body) {
        console.log('err = '+err);
        console.log('res = '+res);
        console.log('body = '+body);
        if(err) {
        var returnJson;
            try {
                returnJson = JSON.parse(body);
             } catch(e) {
                callback(new Error('Unknown response'), null, body);
        } else {
            returnJson = body;
        callback(null, returnJson);


Hi, you can try this package : https://atmospherejs.com/meteorhacks/async


Yes, I’ve looked briefly at Arunodas asyn package and see it could fit here. His approach is similar though, and Meteor.wrapAsync should really work here, so I’m still hoping to figure out why this isn’t working for me.


what about pasting these outputs when there is XY console.logs, but nothing provided to us ?


Hi, I try it and get result in error exception.

if (Meteor.isServer) {
        getMetadata: function (url, options) {
            try {
                check(url, String);
                var options = options || {md5 : true},
                    url = url + '/metadata'
                var getMetadataSynchronously = Meteor.wrapAsync(getInfoFilePicker);
                console.log('Begin get metadata.............')
                var result = getMetadataSynchronously(url, options);
            } catch (ex) {
                console.log('Exception : ', ex);

    function getInfoFilePicker(url, options, cb) {
        var request = Meteor.npmRequire('request');
        request({url: url, qs: options}, function (err, res, body) {
            if (err)  console.log(err);

In Meteor shell

> Meteor.call('getMetadata','https://www.filepicker.io/api/file/DCL5K46FS3OIxb5iuKby')

I20150901-10:14:29.585(7)? Begin get metadata.............
I20150901-10:14:30.979(7)? Exception :  { [Error: {"md5": "641ff9f723c13acbfb139f6aa33a04b4"}] stack: [Getter] }

So, Meteor.wrapAsync working but get exception…


I’m not sure what you are asking for exactly? The log file?


Interesting… looks like those getter/setter errors indicate more information can be retrieved:

I’ll have to play with this and get back to you