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

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) { ...@@ -47,11 +47,6 @@ ConnectionManager.prototype.connect = function(config) {
var connection = new self.lib.Connection(connectionConfig); var connection = new self.lib.Connection(connectionConfig);
connection.lib = self.lib; 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) { connection.on('connect', function(err) {
if (!err) { if (!err) {
resolve(connection); resolve(connection);
...@@ -93,12 +88,23 @@ ConnectionManager.prototype.connect = function(config) { ...@@ -93,12 +88,23 @@ ConnectionManager.prototype.connect = function(config) {
break; 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) { ConnectionManager.prototype.disconnect = function(connection) {
// Dont disconnect a connection that is already disconnected // Dont disconnect a connection that is already disconnected
if (!connection.connected) { if (!!connection.closed) {
return Promise.resolve(); return Promise.resolve();
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!