fix(pg-pool): don't throw on readonly .message e.g. ErrorEvent, preserve original exception (#3374)

* fix(pg-pool): preserve original error on connection timeout, don't throw on readonly .message e.g. ErrorEvent

Fixes https://github.com/brianc/node-postgres/issues/3373

* Fix lint
This commit is contained in:
Andy Young 2025-02-10 22:27:55 +00:00 committed by GitHub
parent 751e7410d9
commit 95bec690b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -244,7 +244,7 @@ class Pool extends EventEmitter {
// remove the dead client from our list of clients
this._clients = this._clients.filter((c) => c !== client)
if (timeoutHit) {
err.message = 'Connection terminated due to connection timeout'
err = new Error('Connection terminated due to connection timeout', { cause: err })
}
// this client wont be released, so move on immediately