Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Aug 22, 2011
1 parent 3faecc2 commit 852da62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/client.js
Expand Up @@ -292,7 +292,8 @@ Client.prototype._handlePacket = function(packet) {
if (!this.connected) {
if (packet.type != Parser.ERROR_PACKET) {
this.connected = true;
this._queue[0].fn();

if (this._queue.length) this._queue[0].fn();
return;
}

Expand Down
14 changes: 12 additions & 2 deletions test/fast/test-client.js
Expand Up @@ -3,14 +3,24 @@ var assert = require('assert');
var test = common.fastOrSlow.fast();
var Client = require(common.dir.lib + '/client');

var client;
test.before(function() {
this.client = new Client();
client = new Client();
});

test('#format() does not manipulate params parameter', function() {
var sql = '?';
var params = [1];

this.client.format(sql, params);
client.format(sql, params);
assert.equal(params.length, 1);
});

// https://github.com/felixge/node-mysql/issues/96
test('Timeout reconnect works with empty queue', function() {
// A non-error packet
var packet = {};

// This must not throw an error
client._handlePacket(packet);
});

0 comments on commit 852da62

Please sign in to comment.