Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

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

Closed
igorzi opened this issue Mar 7, 2012 · 2 comments
Closed

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

igorzi opened this issue Mar 7, 2012 · 2 comments
Labels

Comments

@igorzi
Copy link

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.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
@ghost ghost assigned igorzi Mar 7, 2012
igorzi pushed a commit to igorzi/node that referenced this issue Mar 7, 2012
fixes nodejs#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
Copy link
Author

igorzi commented Mar 7, 2012

fixed in igorzi/node@cfd18db

@koichik @isaacs please review

@koichik
Copy link

koichik commented Mar 7, 2012

@igorzi - LGTM, thanks.

@igorzi igorzi closed this as completed in 5ad0140 Mar 7, 2012
isaacs added a commit that referenced this issue Mar 13, 2012
* 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 igorzi removed their assignment Aug 31, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants