我想用Meteor.wrapAsync包装superagent NPM,一切工作正常,直到下面的代码的最后一行,这导致我的流星应用程序崩溃。流星 - 用Meteor.wrapAsync包装NPMs()
var superagent = Meteor.npmRequire('superagent');
// Example of how superagent works
superagent.get('http://127.0.0.1:8080/json/', function(result){
console.log(result); // Works, shows the result
});
// This appears to work too
var agentAsync = Meteor.wrapAsync(superagent.get);
// This crashes app
agentAsync('http://127.0.0.1:8080/json/');
我还试图通过上下文来wrapAsync()和它没有什么区别:
var agentAsync = Meteor.wrapAsync(superagent.get, superagent);
这里是控制台输出:
W20141124-17:31:32.094(0)? (STDERR)
W20141124-17:31:32.136(0)? (STDERR) /home/ciwolsey/.meteor/packages/meteor-tool/.1.0.35.1bjny7b++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:206
W20141124-17:31:32.136(0)? (STDERR) throw(ex);
W20141124-17:31:32.137(0)? (STDERR) ^
W20141124-17:31:32.137(0)? (STDERR) [object Object]
W20141124-17:31:32.137(0)? (STDERR) at Object.Future.wait (/home/ciwolsey/.meteor/packages/meteor-tool/.1.0.35.1bjny7b++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:326:15)
W20141124-17:31:32.137(0)? (STDERR) at packages/meteor/helpers.js:118
W20141124-17:31:32.137(0)? (STDERR) at app/server/main.js:5:1
W20141124-17:31:32.137(0)? (STDERR) at app/server/main.js:8:3
W20141124-17:31:32.137(0)? (STDERR) at /home/ciwolsey/projects/hello/.meteor/local/build/programs/server/boot.js:168:10
W20141124-17:31:32.138(0)? (STDERR) at Array.forEach (native)
W20141124-17:31:32.138(0)? (STDERR) at Function._.each._.forEach (/home/ciwolsey/.meteor/packages/meteor-tool/.1.0.35.1bjny7b++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20141124-17:31:32.138(0)? (STDERR) at /home/ciwolsey/projects/hello/.meteor/local/build/programs/server/boot.js:82:5
=> Exited with code: 8
在流星github上关于这个https://github.com/meteor/meteor/issues/3176 – 2014-11-25 07:21:17
打开了一个问题很好的解释,谢谢你做出这样的努力,并提交它作为一个问题;) – ciwolsey 2014-11-26 00:40:28