From 5079c1e0c41f431ac2e02c40ebd875d8fbb34004 Mon Sep 17 00:00:00 2001 From: Victor Widell Date: Sat, 29 Mar 2014 16:45:00 +0100 Subject: [PATCH] Added missing argument to handleError method call. Before the change, it would crash with a very unhelpful error message: [project path]/node_modules/pg/lib/query.js:92 connection.sync(); ^ TypeError: Cannot call method 'sync' of undefined at Query.handleError ([project path]/node_modules/pg/lib/query.js:92:16) at Client.connect ([project path]/node_modules/pg/lib/client.js:178:24) at g (events.js:185:14) at EventEmitter.emit (events.js:85:17) at Socket. ([project path]/node_modules/pg/lib/connection.js:60:10) at Socket.EventEmitter.emit (events.js:85:17) at TCP.onread (net.js:424:51) After the change, it reports a much more helpful error running query [Error: Stream unexpectedly ended during query execution] --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 490e1d18..7eab164b 100644 --- a/lib/client.js +++ b/lib/client.js @@ -175,7 +175,7 @@ Client.prototype.connect = function(callback) { con.once('end', function() { if(self.activeQuery) { var disconnectError = new Error('Stream unexpectedly ended during query execution'); - self.activeQuery.handleError(disconnectError); + self.activeQuery.handleError(disconnectError, con); self.activeQuery = null; } self.emit('end');