Skip to content

Commit

Permalink
fix: wait all the commands in a pipeline before sending #411 (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
luin authored Dec 15, 2016
1 parent 26dd792 commit bfa879a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ Redis.prototype.sendCommand = function (command, stream) {
}

var writable = (this.status === 'ready') ||
((this.status === 'connect') && commands.hasFlag(command.name, 'loading'));
(!stream && (this.status === 'connect') && commands.hasFlag(command.name, 'loading'));
if (!this.stream) {
writable = false;
} else if (!this.stream.writable) {
Expand Down
15 changes: 15 additions & 0 deletions test/functional/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,20 @@ describe('pipeline', function () {
done();
});
});

it('should batch all commands before ready event', function (done) {
var redis = new Redis();
redis.on('connect', function () {
redis.pipeline().info().config('get', 'maxmemory').exec(function (err, res) {
expect(err).to.eql(null);
expect(res).to.have.lengthOf(2);
expect(res[0][0]).to.eql(null);
expect(typeof res[0][1]).to.eql('string');
expect(res[1][0]).to.eql(null);
expect(Array.isArray(res[1][1])).to.eql(true);
done();
});
});
});
});
});
17 changes: 17 additions & 0 deletions test/functional/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,21 @@ describe('transaction', function () {
});
});
});

describe('#exec', function () {
it('should batch all commands before ready event', function (done) {
var redis = new Redis();
redis.on('connect', function () {
redis.multi().info().config('get', 'maxmemory').exec(function (err, res) {
expect(err).to.eql(null);
expect(res).to.have.lengthOf(2);
expect(res[0][0]).to.eql(null);
expect(typeof res[0][1]).to.eql('string');
expect(res[1][0]).to.eql(null);
expect(Array.isArray(res[1][1])).to.eql(true);
done();
});
});
});
});
});

0 comments on commit bfa879a

Please sign in to comment.