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

Commit 576b9555 by Jan Aagaard Meier

Mark a pg connection as invalid on connection err. Builds on PR #2557 by @jawj

1 parent f9db7aa5
Showing with 9 additions and 0 deletions
...@@ -82,6 +82,11 @@ ConnectionManager.prototype.connect = function(config) { ...@@ -82,6 +82,11 @@ ConnectionManager.prototype.connect = function(config) {
reject(new Error('Connection timed out')); reject(new Error('Connection timed out'));
} }
}); });
// Don't let a Postgres restart (or error) to take down the whole app
connection.on('error', function(err, client) {
connection._invalid = true;
});
}).tap(function (connection) { }).tap(function (connection) {
if (self.sequelize.config.keepDefaultTimezone) return; if (self.sequelize.config.keepDefaultTimezone) return;
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
...@@ -100,4 +105,8 @@ ConnectionManager.prototype.disconnect = function(connection) { ...@@ -100,4 +105,8 @@ ConnectionManager.prototype.disconnect = function(connection) {
}); });
}; };
ConnectionManager.prototype.validate = function(connection) {
return connection._invalid === undefined;
};
module.exports = ConnectionManager; module.exports = ConnectionManager;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!