Hi,
We have started to see this in our console after a crash. We applied a quick patch but didn't go into full review of if within the system - yet.
TypeError: Cannot read property 'onLost' of undefined
at Client.onError (/caliber/microservices/node_modules/pg-promise/lib/connect.js:89:29)
at emitOne (events.js:101:20)
at Client.emit (events.js:191:7)
at Client.(/caliber/microservices/node_modules/pg/lib/client.js:226:14)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:86:13)
at Connection.emit (events.js:188:7)
at Socket.(/caliber/microservices/node_modules/pg/lib/connection.js:138:10)
at emitNone (events.js:91:20)
at Socket.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9
the ad-hock patch :
if (ctx.cnOptions && typeof ctx.cnOptions.onLost === 'function' && !ctx.notified) {
I'm having difficulty reproducing it, since cnOptions is always set: https://github.com/vitaly-t/pg-promise/blob/master/lib/database.js#L218
Could you add more details to it, please, possibly with the usage example.
I have reproduced the issue. It comes from the fact that only a direct-connection method would provide a non-null connection options, while top-level queries and tasks would not, hence the crash.
I will be fixing it asap.
Fixed in v6.3.5.
@calibermind Thank you for reporting!
Most helpful comment
Fixed in v6.3.5.
@calibermind Thank you for reporting!