geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Problem with Mysql adapter reconnect-behaviour #188

Closed evgk closed 5 years ago

evgk commented 10 years ago

lib/adapters/sql/mysql.js

evgk commented 10 years ago

As the error-handler on the connection is set only in init function: this.init = function () { var self = this; this.client = this._getClient(); this.client.on('error', function(err) {

but not in _handleDisconnect, where the connection class is also created: this._handleDisconnect = function (callback) { var self = this; setTimeout(function() { self.client = self._getClient();

then it tries to reconnect after there is some issue only once - if e.g. mysql goes down the 2nd time, then it won't try to reconnect anymore.

mde commented 10 years ago

Could you put together a PR to fix this?