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

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
esdoc
package-lock.json
yarn.lock
*.code-workspace
\ No newline at end of file
......@@ -159,12 +159,14 @@ class ConnectionManager {
}
},
destroy: mayBeConnection => {
if (mayBeConnection instanceof Error) {
return Promise.resolve();
if (mayBeConnection.queryType === undefined) {
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)
.tap(() => { debug('connection destroy'); });
return this.pool[mayBeConnection.queryType].destroy(mayBeConnection);
},
clear: () => {
return Promise.join(
......@@ -188,7 +190,14 @@ class ConnectionManager {
})
.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
}, {
Promise: config.pool.Promise,
......@@ -210,7 +219,14 @@ class ConnectionManager {
})
.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
}, {
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!