Result of async.timeout() only works the first time you call it.
See original GitHub issueWhat 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Combination of async function + await + setTimeout
The result is an asynchronous call that does not run more often than twice a second, with a timeout of 5 seconds in...
Read more >How to Add a Timeout Limit to Asynchronous JavaScript ...
In order to create the timeout, we will use an asynchronous function that takes in a Promise, as well as a time limit....
Read more >On awaiting a task with a timeout in C# - The Old New Thing
Say you have an awaitable object, and you want to await it, ... The value in something is the result of GetSomethingAsync() or...
Read more >Understanding the Event Loop, Callbacks, Promises, and ...
setTimeout takes two arguments: the function it will run asynchronously, and the amount of time it will wait before calling that function. In ......
Read more >setTimeout() - Web APIs | MDN
Working with asynchronous functions ... setTimeout() is an asynchronous function, meaning that the timer function will not pause execution of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @acjohnso25, I believe you’re right that this is bug. It should only give a
ETIMEDOUT
error on the first call. Thanks for the report, we’ll fix as soon as possible.Fixed in v2.4.1