var maxConcurrent = 1;var maxQueue = Infinity;var queue = new Queue(maxConcurrent, maxQueue);app.get('/version/:user/:repo', function (req, res, next) { queue.add(function () { // Assume that this action is a way too expensive // Call of this function will be delayed on second request return downloadTarballFromGithub(req.params); }) .then(parseJson('package.json')) .then(function (package) { res.send(package.version); }) .catch(next);
Getting number of pending promises and queue(buffered promises) length