[英]How can I make vows wait 60s for a callback to happen
I've written some code that connects to an FTP server and lists a very long directory. 我已经写了一些连接到FTP服务器的代码,并列出了一个很长的目录。 It can take 40+ seconds to get a response.
得到响应可能需要40秒钟以上的时间。
I've written some code to start testing this but I get Errored >> callback not fired. 我已经编写了一些代码来开始对此进行测试,但是我得到Error >>回调未触发。
Is there a way to instruct Vows or Node to just chill for a bit and wait for the callbacks to fire say, up to some configurable amount of time? 有没有一种方法可以指示Vows或Node放松一下,并等待回调触发,直到达到可配置的时间量?
Here's my vows code: vows.describe('FTP Downloader Suite').addBatch({ 'FTP Downloader' : { topic: function() { var promise = new(events.EventEmitter); 这是我的誓言代码:vows.describe('FTP Downloader Suite')。addBatch({'FTP Downloader':{topic:function(){var promise = new(events.EventEmitter);
var lastMomentDownloaded = moment();
lastMomentDownloaded.subtract('minute', 1);
ftpDownloader.getNewPathsToDownload(config, lastMomentDownloaded, function(err, res) {
if (err) { promise.emit('error', err, res) }
else { promise.emit('success', err, res) }
});
return promise;
},
'can be accessed': function(err, stat) {
assert.isNull(err); // we have no error
assert.isArray(stat); // we have a result
},
'is not empty': function(err, stat) {
assert.isNotZero(stat.length);
},
'is shorter than 100 paths': function(err, stat) {
assert.isTrue(stat.length < 100);
},
'contains paths matching the config': function(err, stat) {
_.each(stat, function(value, key, list) {
console.log(value);
});
}
}
}).export(module);
Thanks! 谢谢!
Vows was obfuscating the source of the problem which is that an error was being thrown. Vows混淆了问题的根源,即引发了错误。 When I switched to nodeunit the issue was obvious.
当我切换到nodeunit时,问题很明显。 Maybe there is a way to improve error logging with vows but I'm done with it.
也许有一种方法可以改善誓约中的错误记录,但是我已经完成了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.