From cb647935bb770e09954e9fca5a5815b97d9da6ee Mon Sep 17 00:00:00 2001 From: brianc Date: Fri, 4 Feb 2011 18:51:23 -0600 Subject: [PATCH] slight readability refactor --- lib/client.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/client.js b/lib/client.js index 5f18b638..2a8972b7 100644 --- a/lib/client.js +++ b/lib/client.js @@ -66,10 +66,18 @@ p.connect = function() { con.password(md5password); }); - con.on('readyForQuery', function() { - self.readyForQuery = true; - this.activeQuery = null; - self.pulseQueryQueue(); + con.once('readyForQuery', function() { + //hook up query handling events to connection + //after the connection initially becomes ready for queries + var ready = function() { + self.readyForQuery = true; + this.activeQuery = null; + self.pulseQueryQueue(); + }; + + con.on('readyForQuery', ready); + ready(); + }); con.on('error', function(error) {