Closed
Description
- Version: Node 10.3.0
- Platform: Linux 4.16.11
- Subsystem: http
index.js
:
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200);
res.on('finish', () => {
console.log('finish');
});
res.on('close', () => {
console.log('close');
});
res.end();
}).listen(3000);
$ nvm use 10; node index.js
Now using node v10.3.0 (npm v6.1.0) # run curl localhost:3000 now
finish
close
^C
$ nvm use 8; node index.js
Now using node v8.9.4 (npm v5.6.0) # run curl localhost:3000 now
finish
^C
$
According to the docs res.close
should only be called if res.end
is not. Unfortunately there doesn't seem to be an event emitted for res.end
so I could not check to see whether or not it was triggered.
However, as is visible in the example above:
- Node 8
finish
event triggeredclose
event not triggered,
- Node 10
finish
event triggeredclose
event triggered