Skip to content

TypeError: Cannot call method 'sync' of undefined #549

Closed
@rngadam

Description

@rngadam

node-postgres 2.8.2

Exception:

/home/rngadam/letsface/src/api-ng/node_modules/pg/lib/query.js:92
    connection.sync();
               ^
TypeError: Cannot call method 'sync' of undefined
    at Query.handleError (/home/rngadam/letsface/src/api-ng/node_modules/pg/lib/query.js:92:16)
    at Client.connect (/home/rngadam/letsface/src/api-ng/node_modules/pg/lib/client.js:167:24)
    at g (events.js:192:14)
    at EventEmitter.emit (events.js:93:17)
    at Socket.<anonymous> (/home/rngadam/letsface/src/api-ng/node_modules/pg/lib/connection.js:60:10)
    at Socket.EventEmitter.emit (events.js:93:17)
    at TCP.onread (net.js:418:51)

the relevant code:

Query.prototype.handleError = function(err, connection) {
  //need to sync after error during a prepared statement
  if(this.isPreparedStatement) {
    connection.sync();
  }

and (in pg/lib/client.js)

  con.once('end', function() {
    if(self.activeQuery) {
      var disconnectError = new Error('Stream unexpectedly ended during query execution');
      self.activeQuery.handleError(disconnectError);
      self.activeQuery = null;
    }
    self.emit('end');
  });

I think this:

 self.activeQuery.handleError(disconnectError);

should be changed to this?

 self.activeQuery.handleError(disconnectError, con);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions