Skip to content

Cannot read property 'handleCommandComplete' of null #1872

Open
@Page-

Description

@Page-

I've hit the following error coming from node-postgres 7.9.0 (latest) which crashes the node process

TypeError: Cannot read property 'handleCommandComplete' of null
  File "/usr/src/app/node_modules/pg/lib/client.js", line 294, col 22, in Connection.<anonymous>
    self.activeQuery.handleCommandComplete(msg, con)
  File "events.js", line 189, col 13, in Connection.emit
  File "domain.js", line 441, col 20, in Connection.EventEmitter.emit
  File "/usr/src/app/node_modules/pg/lib/connection.js", line 125, col 12, in Socket.<anonymous>
    self.emit(eventName, msg)
  File "events.js", line 189, col 13, in Socket.emit
  File "domain.js", line 441, col 20, in Socket.EventEmitter.emit
  File "_stream_readable.js", line 284, col 12, in addChunk
  File "_stream_readable.js", line 265, col 11, in readableAddChunk
  File "_stream_readable.js", line 220, col 10, in Socket.Readable.push
  File "internal/stream_base_commons.js", line 94, col 17, in TCP.onStreamRead [as onread]

I'm using a connection pool via new pg.Pool(config) but as far as I'm aware no other modules that would interact with node-postgres internals at all

I haven't got a reproduction as I've only seen it coupled with a read replica that is falling behind the primary and causing Client has encountered a connection error and is not queryable and terminating connection due to conflict with recovery errors to be emitted and would expect that to be what's causing the activeQuery to be nulled. A simple fix would be to add a guard to https://github.com/brianc/node-postgres/blob/v7.9.0/lib/client.js#L293-L295 but I'm not sure if you'd accept that as a patch and if/where you would want to emit it as an event instead - if you could offer guidance on how you'd like to see this solved then I'm very happy to send a PR

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