简体   繁体   English

我如何让誓言等60秒钟才发生回调

[英]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.

相关问题 aws beanstalk nodejs:如何覆盖 nginx 的 60 秒超时 - aws beanstalk nodejs: how to override 60s timeout of nginx 如何通过誓言测试此功能? - How can this function be tested with vows? 如何让lambda等待回调? - How to make lambda wait for callback? 如何使用Vows和Node.js解决“未触发回调” - How to solve “callback not fired” with Vows and Node.js Express.js 文件上传:60 秒超时和 HTTP 连接超时错误 - Express.js File Upload : 60s timeouts and HTTP connection timeout errors 我无法在Windows上使用“vows test / *”命令运行测试。 如何使用它? 的node.js - I can't run test with “vows test/*” command on windows. How to use it? node.js 如何在CoffeeScript中进行回调 - How can I make a callback in CoffeeScript NGINX 和 nodejs 上游连接在连接到上游时超时,但请求将在 60 秒后得到响应 - NGINX and nodejs upstream connection timed out while connecting to upstream but request will get responded after exactly 60s 如何让“ng serve”等待“ng build”完成? - How can I make “ng serve” wait for “ng build” to finish? 如何让主节点等待工作人员在 nodejs 集群中完成 - How can I make the master wait for workers to complete in nodejs cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM