stream与nodejs(io.js),backpressure和drain,`end`事件被调用两次

我有这个代码。 end事件被激发两次。 我不明白为什么。 任何提示? 谢谢。

 var chance = require('chance').Chance(); require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); function generateMore() { while(chance.bool({likelihood: 95})) { var shouldContinue = res.write( chance.string({length: (16 * 1024) - 1}) ); if(!shouldContinue) { console.log('Backpressure'); return res.once('drain', generateMore); } } res.end('\nThe end...\n', function() { console.log('All data was sent'); // I see this log two times }); } generateMore(); }).listen(8080, function () { console.log('Listening'); }); 

因为当你打开URL时,浏览器尝试获取favicon.ico并向服务器发送两个请求。