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

You need to sign in or sign up before continuing.
Commit 93e5507d by Mick Hansen

Merge pull request #3285 from mbroadst/mssql-disconnect-issue

fix tedious error handling
2 parents fcceefdf 421dd28a
Showing with 12 additions and 6 deletions
......@@ -47,11 +47,6 @@ ConnectionManager.prototype.connect = function(config) {
var connection = new self.lib.Connection(connectionConfig);
connection.lib = self.lib;
// don't let tedious errors take down the entire application
connection.on('error', function(err) {
connection._invalid = true;
});
connection.on('connect', function(err) {
if (!err) {
resolve(connection);
......@@ -93,12 +88,23 @@ ConnectionManager.prototype.connect = function(config) {
break;
}
});
if (config.pool.handleDisconnects) {
connection.on('error', function (err) {
switch (err.code) {
case 'ESOCKET':
case 'ECONNRESET':
self.pool.destroy(connection);
}
});
}
});
};
ConnectionManager.prototype.disconnect = function(connection) {
// Dont disconnect a connection that is already disconnected
if (!connection.connected) {
if (!!connection.closed) {
return Promise.resolve();
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!