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

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

@igorzi

Description

@igorzi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions