mirror of
https://github.com/knex/knex.git
synced 2026-01-05 19:47:55 +00:00
fix: attach error handler early enough (#5552)
This commit is contained in:
parent
2a6c20f27c
commit
e7dc724fcf
@ -80,6 +80,14 @@ class Client_PG extends Client {
|
||||
_acquireOnlyConnection() {
|
||||
const connection = new this.driver.Client(this.connectionSettings);
|
||||
|
||||
connection.on('error', (err) => {
|
||||
connection.__knex__disposed = err;
|
||||
});
|
||||
|
||||
connection.on('end', (err) => {
|
||||
connection.__knex__disposed = err || 'Connection ended unexpectedly';
|
||||
});
|
||||
|
||||
return connection.connect().then(() => connection);
|
||||
}
|
||||
|
||||
@ -90,14 +98,6 @@ class Client_PG extends Client {
|
||||
|
||||
return this._acquireOnlyConnection()
|
||||
.then(function (connection) {
|
||||
connection.on('error', (err) => {
|
||||
connection.__knex__disposed = err;
|
||||
});
|
||||
|
||||
connection.on('end', (err) => {
|
||||
connection.__knex__disposed = err || 'Connection ended unexpectedly';
|
||||
});
|
||||
|
||||
if (!client.version) {
|
||||
return client.checkVersion(connection).then(function (version) {
|
||||
client.version = version;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user