I am using aync.parallel to run two functions in parallel. The functions request RSS feeds. Then the RSS feeds are parsed and added to my web page.
But for some reason async.parallel
runs the callback method without waiting until the two functions have completed
Once the tasks have completed, the results are passed to the final callback as an array.
My code.
require('async').parallel([ function(callback) {
fetchRss(res, bbcOpts); // Needs time to request and parse
callback();
}, function(callback) {
// Very fast.
callback();
} ], function done(err, results) {
if (err) {
throw err;
}
res.end("Done!");
});
In fact I only have "Done!" on my web page. Why?
Why do I need to call res.end()
?
The Node.JS documentation says:
The method, response.end(), MUST be called on each response.
If I don't call it, my web page will be being "downloaded" (I mean a progress bar in the address line of my browser).