大家好我尝试在Meteor中使用proxy-verifier NPM package,如下所示:
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;
}
}
它运作良好但有时(可能在检查一些代理)它返回异常:
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)
我在Meteor.wrapAsync
方法中使用checkProxy
是否与此相关?请指导我如何找到并解决此问题。