我想用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