Exception in callback of async function: Error: Future resolved more than once

Hi guys I try to use proxy-verifier NPM package like below:

import ProxyVerifier from 'proxy-verifier';

// this is my method call on server startup
Jobs.find().forEach((job) => {
 Meteor.call("checkProxy", job.proxy, (error, result) => {
  if (error) {
   console.log("error: " + error);
  } else {
   console.log("result: " + result); // result is true or false
   let inc;
   inc = result ? 1 : -1;
   Jobs.update({
    _id: job._id
   }, {
    $inc: {
     count: inc
    }
   });
  }
 });
});

// this is my method
checkProxy(proxy) {
 this.unblock();

 let syncTestProtocol = Meteor.wrapAsync(ProxyVerifier.testProtocol);
 let testResult;
 try {
  testResult = syncTestProtocol(proxy);
  return testResult.ok;
 } catch (error) {
  return false;
 }
}

It’s works well but sometimes (maybe on check some proxy) it return below exception:

I20160724-07:48:18.391(4.5)? Exception in callback of async function: Error: Future resolved more than once
I20160724-07:48:18.391(4.5)?     at Object.Future.return (/home/username/.meteor/packages/meteor-tool/.1.3.5_1.emd1tx++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:261:10)
I20160724-07:48:18.391(4.5)?     at Object.<anonymous> (/home/username/.meteor/packages/meteor-tool/.1.3.5_1.emd1tx++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:349:16)
I20160724-07:48:18.391(4.5)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)
I20160724-07:48:18.392(4.5)? Exception in callback of async function: Error: Future resolved more than once
I20160724-07:48:18.392(4.5)?     at Object.Future.return (/home/username/.meteor/packages/meteor-tool/.1.3.5_1.emd1tx++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:261:10)
I20160724-07:48:18.393(4.5)?     at Object.<anonymous> (/home/username/.meteor/packages/meteor-tool/.1.3.5_1.emd1tx++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:349:16)
I20160724-07:48:18.393(4.5)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)

I used Meteor.wrapAsync in checkProxy block is it related to this? Please guide me how to find and fix this issue.

Hi @diegoolivier, Thanks for your attention.
I read that topic but I can’t understand who I can fix above code. Can you help me to fix this?

You are right. I answered too quickly : you are just using some features provided to you but didn’t write the underlying code. I had a VERY QUICK look and I don’t see anything that is obviously wrong.

My guess would be to try replacing wrapAsync with a direct Promise / async / await call to see if the problem remains.