不要怂,就是干,撸起袖子干!

Commit a1ccf047 by Michael Kaufman Committed by Sushant

fix(pool): destroy pooled errors properly with replication (#11140)

1 parent a32263f3
...@@ -20,3 +20,4 @@ coverage ...@@ -20,3 +20,4 @@ coverage
esdoc esdoc
package-lock.json package-lock.json
yarn.lock yarn.lock
*.code-workspace
\ No newline at end of file
...@@ -159,12 +159,14 @@ class ConnectionManager { ...@@ -159,12 +159,14 @@ class ConnectionManager {
} }
}, },
destroy: mayBeConnection => { destroy: mayBeConnection => {
if (mayBeConnection instanceof Error) { if (mayBeConnection.queryType === undefined) {
return Promise.resolve(); return Promise.all([
this.pool.read.destroy(mayBeConnection).catch(/Resource not currently part of this pool/, () => {}),
this.pool.write.destroy(mayBeConnection).catch(/Resource not currently part of this pool/, () => {})
]);
} }
return this.pool[mayBeConnection.queryType].destroy(mayBeConnection) return this.pool[mayBeConnection.queryType].destroy(mayBeConnection);
.tap(() => { debug('connection destroy'); });
}, },
clear: () => { clear: () => {
return Promise.join( return Promise.join(
...@@ -188,7 +190,14 @@ class ConnectionManager { ...@@ -188,7 +190,14 @@ class ConnectionManager {
}) })
.catch(err => err); .catch(err => err);
}, },
destroy: connection => this._disconnect(connection), destroy: mayBeConnection => {
if (mayBeConnection instanceof Error) {
return Promise.resolve();
}
return this._disconnect(mayBeConnection)
.tap(() => { debug('connection destroy'); });
},
validate: config.pool.validate validate: config.pool.validate
}, { }, {
Promise: config.pool.Promise, Promise: config.pool.Promise,
...@@ -210,7 +219,14 @@ class ConnectionManager { ...@@ -210,7 +219,14 @@ class ConnectionManager {
}) })
.catch(err => err); .catch(err => err);
}, },
destroy: connection => this._disconnect(connection), destroy: mayBeConnection => {
if (mayBeConnection instanceof Error) {
return Promise.resolve();
}
return this._disconnect(mayBeConnection)
.tap(() => { debug('connection destroy'); });
},
validate: config.pool.validate validate: config.pool.validate
}, { }, {
Promise: config.pool.Promise, Promise: config.pool.Promise,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!