Skip to content

Result of async.timeout() only works the first time you call it. #1418

@acjohnso25

Description

@acjohnso25

What version of async are you using? 2.4.0

Which environment did the issue occur in (Node version/browser version) Node.js 4.7.0

What did you do? Please include a minimal reproducable case illustrating issue.

const async = require('async');

var asyncFn = function (i, done) {
    if (i < 1) {
        setTimeout(done, 200);
    } else {
        setImmediate(done);
    }
};

// wrap function once, call 10 times
var timeoutFn = async.timeout(asyncFn, 100);
var j = 0;
async.whilst(
    function () {
        return j < 10;
    },
    function (done) {
        timeoutFn(j++, function (err) {
            console.log('Test 1 #' + j, err);
            done();
        });
    },
    function (err) {
    }
);

What did you expect to happen? Should only get timeout error the first time it's called.

What was the actual result? Timeout occurs every time it's called, even though the underlying function only takes too long the first time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions