while playing with node threads, I noticed that almost every tutorial teaches something like:
// Get Google home page. require('http').get("http://www.google.com/", function(response) { // The callback provides the response readable stream. // Then, we open our output text stream. var outStream = require('fs').createWriteStream("out.txt"); // Pipe the input to the output, which writes the file. response.pipe(outStream); });
But, in my opinion, this is quite dangerous code. What happens if a file stream throws some kind of exception? I think the file stream may leak memory, because according to the documents the file stream is clearly not close.
Should I take care? In my node.js option, threads should handle situations ...
Kr0e Dec 08 '13 at 2:11 2013-12-08 02:11
source share