Why is the waterfall so slow?

I am using an asynchronous module (see https://github.com/caolan/async ) for Node.js and my question is ... Why is the waterfall so slow?

This part of the code takes 4 seconds to complete ...

App.post("/form", function(request, response) { Async.waterfall([ function(callback) { console.log("1."); callback(null, "some data"); }, function(data, callback) { console.log("2."); callback(null, "some data"); }, function(data, callback) { console.log("3."); callback(null, "some data"); } ], function(error, document) { console.log("4."); console.log("Done."); response.send(); // Takes 4 seconds }); } 

Output

 1. 2. // After 4 seconds 3. 4. Done. 

Thanks for the answer!

+4
source share
1 answer

This is just another Node.js Error.

Using process.nextTick inside another process.nextTick during http.ServerResponse interrupt.

 var http = require('http'); http.createServer(function(req, res) { var now = new Date(); process.nextTick(function() { process.nextTick(function() { console.log(new Date() - now); res.writeHead({}); res.end('foooooo'); }); }); }).listen(3000); 

It takes ages, async.js calls back callbacks from other callbacks called through process.nextTick , which causes the above error to fire.

Quick fix: async.js line 63 modifiy async.nextTick uses only setTimeout .

Error: I registered issue .

+3
source

All Articles