-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
- 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
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.