Connection: defer fetch 'end' event until next tick

Due to streams2' use of process.nextTick, without this patch body streams' 'end' events will emit after the fetch 'end' event, causing some confusion.
fork
mscdex 11 years ago
parent 517367ef19
commit d80b873a6e

@ -1088,9 +1088,12 @@ Connection.prototype._resTagged = function(info) {
}
if (req.bodyEmitter) {
var bodyEmitter = req.bodyEmitter;
if (err)
req.bodyEmitter.emit('error', err);
req.bodyEmitter.emit('end');
bodyEmitter.emit('error', err);
process.nextTick(function() {
bodyEmitter.emit('end');
});
} else {
req.cbargs.unshift(err);
req.cb && req.cb.apply(this, req.cbargs);

Loading…
Cancel
Save