- Version: v4.5.0+
- Platform: all
- Subsystem: http
@davidmarkclements brought to my attention an issue that came about in node v4.5.0 where an http.IncomingMessage's 'end' event wasn't being emitted properly when piping to a stream.Writable. The event does get emitted in node v4.4.7 however. Bisecting reveals 6f312b3 as the offending commit.
Test case:
var http = require('http');
var Writable = require('stream').Writable;
http.createServer((req, res) => {
req.on('end', function() {
console.log('end');
});
var ws = new Writable({
write: function(data, enc, cb) {
cb();
this.emit('finish');
}
});
req.pipe(ws);
}).listen(8080)
It doesn't matter which order the cb() and this.emit('finish') are in or if the emit() is wrapped in a process.nextTick(). If emit() is wrapped in a setImmediate() though, then the 'end' event gets emitted.
/cc @trevnorris @indutny
@davidmarkclements brought to my attention an issue that came about in node v4.5.0 where an
http.IncomingMessage's'end'event wasn't being emitted properly when piping to astream.Writable. The event does get emitted in node v4.4.7 however. Bisecting reveals 6f312b3 as the offending commit.Test case:
It doesn't matter which order the
cb()andthis.emit('finish')are in or if theemit()is wrapped in aprocess.nextTick(). Ifemit()is wrapped in asetImmediate()though, then the'end'event gets emitted./cc @trevnorris @indutny