This repository has been archived by the owner. It is now read-only.

Inaccurate ClientResponse 'end' event documentation #4116

egirshov opened this Issue Oct 11, 2012 · 4 comments


None yet
2 participants

Another minor documentation issue, it says:

After emitted no other events will be emitted on the response.

Although I guess it means "no 'data' events will be emitted", since there is a case then a 'close' event is emitted after 'end'.


bnoordhuis commented Oct 11, 2012

since there is a case then a 'close' event is emitted after 'end'.

You mean http.ClientResponse, right? The documentation is right, you're not supposed to get a 'close' event after an 'end' event. If you do, it's a bug.

Yes, I was referring to http.ClientResponse. Here is sample code:

var http = require('http');
http.createServer(function (req, res) {
    req.on('end', function () {
        setTimeout(function () { res.end('Blah.'); }, 5000);
var request = http.request({port: 8000}, function (response) {
    setTimeout(function () {
        response.once('end', function () {
            console.log('http.ClientResponse `end`');
            response.once('close', function () {
                console.log('http.ClientResponse `close` too');
    }, 2000);

bnoordhuis added a commit to bnoordhuis/node that referenced this issue Oct 12, 2012

doc: rectify http.ClientResponse close/end events
* The 'close' event doesn't emit an error object.

* It's possible for a 'close' event to come after an 'end' event, contrary to
  what the documentation said.

Fixes #4116.

bnoordhuis commented Oct 12, 2012

Right, I was wrong (as was that part of the documentation - it's documented correctly elsewhere). Can someone review c8af471?


bnoordhuis commented Oct 13, 2012

Fixed in 4a23add.

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