joyent/node — Issue #2888: end event emitted twice when response is pauses/resumed
Author: igorzi
Created: 2012-03-07 09:20:05+00:00
State: open

If a response is paused and then resumed, and if the underlying socket is closed while the response is paused - the end event gets fired twice.

Here's the code:

```javascript
var http = require('http');

var server = http.Server(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
server.close();
});

server.listen(1234, function() {
http.get({
port: 1234,
headers: { connection: 'close' }
}, function(res) {
res.on('data', function(chunk) {
res.pause();
});

res.on('end', function() {
res.resume();
console.log('end callback');
});
});
});
```

output:

end callback
end callback