1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Use process.nextTick to uncork

This commit is contained in:
Ruben Bridgewater
2016-04-29 06:11:12 +02:00
parent a1755b91fb
commit 340cddb6d1
4 changed files with 19 additions and 11 deletions

View File

@@ -437,8 +437,9 @@ RedisClient.prototype.on_ready = function () {
self.pipeline = false;
self.fire_strings = true;
if (self.stream.uncork) {
// TODO: Consider using next tick here. See https://github.com/NodeRedis/node_redis/issues/1033
process.nextTick(function () {
self.stream.uncork();
});
}
};

View File

@@ -674,8 +674,10 @@ describe("The 'multi' method", function () {
// The commands should still be fired, no matter that the socket is destroyed on the same tick
client.multi().set('foo', 'bar').get('foo').exec();
// Abort connection before the value returned
process.nextTick(function () {
client.stream.destroy();
});
});
it('indivdual commands work properly with multi', function (done) {
// Neither of the following work properly in a transactions:

View File

@@ -1112,8 +1112,10 @@ describe('The node_redis client', function () {
}
multi.exec();
assert.equal(client.command_queue_length, 15);
process.nextTick(function () {
helper.killConnection(client);
});
});
var end = helper.callFuncAfter(done, 3);
client.on('error', function (err) {
@@ -1203,8 +1205,10 @@ describe('The node_redis client', function () {
}
multi.exec();
assert.equal(client.command_queue.length, 15);
process.nextTick(function () {
helper.killConnection(client);
});
});
var end = helper.callFuncAfter(done, 3);
client.on('error', function (err) {

View File

@@ -491,18 +491,19 @@ describe('publish/subscribe', function () {
});
sub2.on('ready', function () {
sub2.batch().psubscribe('*', helper.isString('*')).exec();
sub2.subscribe('/foo');
sub2.subscribe('/foo', function () {
pub.pubsub('numsub', '/foo', function (err, res) {
assert.deepEqual(res, ['/foo', 2]);
});
// sub2 is counted twice as it subscribed with psubscribe and subscribe
pub.publish('/foo', 'hello world', helper.isNumber(3));
});
sub2.on('pmessage', function (pattern, channel, message) {
assert.strictEqual(pattern.inspect(), new Buffer('*').inspect());
assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect());
assert.strictEqual(message.inspect(), new Buffer('hello world').inspect());
sub2.quit(done);
});
pub.pubsub('numsub', '/foo', function (err, res) {
assert.deepEqual(res, ['/foo', 2]);
});
// sub2 is counted twice as it subscribed with psubscribe and subscribe
pub.publish('/foo', 'hello world', helper.isNumber(3));
});
});