From dfae2cb8d0199afe3515f728ebb2520b6781a46f Mon Sep 17 00:00:00 2001 From: mscdex Date: Wed, 3 Jul 2013 15:33:24 -0400 Subject: [PATCH] Connection: defer message 'attributes' and 'end' events until next tick --- lib/Connection.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index a064347..ca12679 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1027,7 +1027,9 @@ Connection.prototype._resUntagged = function(info) { if (i === 0) { if (!msg.ended) { msg.ended = true; - msgEmitter.emit('end'); + process.nextTick(function() { + msgEmitter.emit('end'); + }); } return; } @@ -1047,8 +1049,10 @@ Connection.prototype._resUntagged = function(info) { } if (toget.length === 0) { - msgEmitter.emit('attributes', attrs); - msgEmitter.emit('end'); + process.nextTick(function() { + msgEmitter.emit('attributes', attrs); + msgEmitter.emit('end'); + }); } else if (msg === undefined) { this._curReq.fetchCache[info.num] = { msgEmitter: msgEmitter,