Saturday 3 June 2017

Does req.abort() always trigger error event in node.js?

Like the title says... I use the HTTPS module for nodejs and when making requests I set timeout and attach an error listener.

    req.setTimeout(6000, function(){
        // mark_completed(true);
        this.abort();
    })
    .on('error', function (e){
        if (!this.aborted){
            // mark_completed(true);
            console.log(e);
        }
    });

In both scenarios I want to execute a function to mark my request as completed.

Is it safe to assume that on error will always be triggered after after the timeout, so that I can place my function exclusively inside the on error event?



via Anonymous

No comments:

Post a Comment