Skip to content
This repository has been archived by the owner on May 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #11 from fcarreiro/patch-1
Browse files Browse the repository at this point in the history
Reconnect when error is fatal
  • Loading branch information
chill117 committed Sep 15, 2016
2 parents 8603e49 + b29042a commit da0e324
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -210,7 +210,7 @@ MySQLConnectionManager.prototype.listenForDisconnect = function() {

debug('Connection error: "' + error.code + '"');

if (error.code == 'PROTOCOL_CONNECTION_LOST') {
if (error.fatal) {
this.disconnected();
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/is-connected.js
Expand Up @@ -67,7 +67,7 @@ describe('MySQLConnectionManager#isConnected()', function() {
manager.once('disconnect', done);

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });
});

it('should return FALSE', function(done) {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('MySQLConnectionManager#isConnected()', function() {
});

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });
});

it('should return TRUE', function(done) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/keep-alive.js
Expand Up @@ -273,7 +273,7 @@ describe('MySQLConnectionManager#', function() {
});

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });
});

it('should not send keep-alive signals', function(done) {
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('MySQLConnectionManager#', function() {
});

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });
});

it('should send keep-alive signals', function(done) {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/reconnect.js
Expand Up @@ -51,7 +51,7 @@ describe('MySQLConnectionManager#', function() {
timeout = setTimeout(done, 50);

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });
});
});
});
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('MySQLConnectionManager#', function() {
}, 80);

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });

});
});
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('MySQLConnectionManager#', function() {
}

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });
});
});
});
Expand Down Expand Up @@ -309,7 +309,7 @@ describe('MySQLConnectionManager#', function() {
});

manager.connection.destroy();
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST' });
manager.connection.emit('error', { code: 'PROTOCOL_CONNECTION_LOST', fatal: true });
});

it('should be able to run a query on the connection object', function(done) {
Expand Down

0 comments on commit da0e324

Please sign in to comment.