end event emitted twice when response is pauses/resumed #2888

igorzi opened this Issue Mar 7, 2012 · 2 comments


None yet
2 participants

igorzi commented Mar 7, 2012

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:

var http = require('http');

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

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

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


end callback
end callback

igorzi was assigned Mar 7, 2012

@igorzi igorzi pushed a commit to igorzi/node that referenced this issue Mar 7, 2012

Igor Zinkovsky Emit end event only once
fixes #2888

Previously a pair of end events would be emitted if a response was
paused/resumed, and the underlying socket was closed while the
response was paused

igorzi commented Mar 7, 2012

fixed in igorzi/node@cfd18db

@koichik @isaacs please review

koichik commented Mar 7, 2012

@igorzi - LGTM, thanks.

igorzi closed this in 5ad0140 Mar 7, 2012

@isaacs isaacs added a commit that referenced this issue Mar 13, 2012

@isaacs isaacs 2012.03.13, Version 0.7.6 (unstable)
* Upgrade v8 to 3.9.17

* Upgrade npm to 1.1.8
  - Add support for os/cpu fields in package.json (Adam Blackburn)
  - Automatically node-gyp packages containing a binding.gyp
  - Fix failures unpacking in UNC shares
  - Never create un-listable directories
  - Handle cases where an optionalDependency fails to build

* events: newListener emit correct fn when using 'once' (Roly Fentanes)

* url: Ignore empty port component (Łukasz Walukiewicz)

* module: replace 'children' array (isaacs)

* tls: parse multiple values of a key in ssl certificate (Sambasiva Suda)

* cluster: support passing of named pipes (Ben Noordhuis)

* Windows: include syscall in fs errors (Bert Belder)

* http: #2888 Emit end event only once (Igor Zinkovsky)

* readline: add multiline support (Rlidwka)

* process: add `process.hrtime()` (Nathan Rajlich)

* net, http, https: add localAddress option (Dmitry Nizovtsev)

* addon improvements (Nathan Rajlich)

* build improvements (Ben Noordhuis, Sadique Ali, T.C. Hollingsworth, Nathan Rajlich)

* add support for "SEARCH" request methods (Nathan Rajlich)

* expose the zlib and http_parser version in process.versions (Nathan Rajlich)

igorzi removed their assignment Aug 31, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment