You've already forked node-redis
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:
3
index.js
3
index.js
@@ -437,8 +437,9 @@ RedisClient.prototype.on_ready = function () {
|
|||||||
self.pipeline = false;
|
self.pipeline = false;
|
||||||
self.fire_strings = true;
|
self.fire_strings = true;
|
||||||
if (self.stream.uncork) {
|
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();
|
self.stream.uncork();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -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
|
// 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();
|
client.multi().set('foo', 'bar').get('foo').exec();
|
||||||
// Abort connection before the value returned
|
// Abort connection before the value returned
|
||||||
|
process.nextTick(function () {
|
||||||
client.stream.destroy();
|
client.stream.destroy();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('indivdual commands work properly with multi', function (done) {
|
it('indivdual commands work properly with multi', function (done) {
|
||||||
// Neither of the following work properly in a transactions:
|
// Neither of the following work properly in a transactions:
|
||||||
|
@@ -1112,8 +1112,10 @@ describe('The node_redis client', function () {
|
|||||||
}
|
}
|
||||||
multi.exec();
|
multi.exec();
|
||||||
assert.equal(client.command_queue_length, 15);
|
assert.equal(client.command_queue_length, 15);
|
||||||
|
process.nextTick(function () {
|
||||||
helper.killConnection(client);
|
helper.killConnection(client);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var end = helper.callFuncAfter(done, 3);
|
var end = helper.callFuncAfter(done, 3);
|
||||||
client.on('error', function (err) {
|
client.on('error', function (err) {
|
||||||
@@ -1203,8 +1205,10 @@ describe('The node_redis client', function () {
|
|||||||
}
|
}
|
||||||
multi.exec();
|
multi.exec();
|
||||||
assert.equal(client.command_queue.length, 15);
|
assert.equal(client.command_queue.length, 15);
|
||||||
|
process.nextTick(function () {
|
||||||
helper.killConnection(client);
|
helper.killConnection(client);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var end = helper.callFuncAfter(done, 3);
|
var end = helper.callFuncAfter(done, 3);
|
||||||
client.on('error', function (err) {
|
client.on('error', function (err) {
|
||||||
|
@@ -491,18 +491,19 @@ describe('publish/subscribe', function () {
|
|||||||
});
|
});
|
||||||
sub2.on('ready', function () {
|
sub2.on('ready', function () {
|
||||||
sub2.batch().psubscribe('*', helper.isString('*')).exec();
|
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) {
|
sub2.on('pmessage', function (pattern, channel, message) {
|
||||||
assert.strictEqual(pattern.inspect(), new Buffer('*').inspect());
|
assert.strictEqual(pattern.inspect(), new Buffer('*').inspect());
|
||||||
assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect());
|
assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect());
|
||||||
assert.strictEqual(message.inspect(), new Buffer('hello world').inspect());
|
assert.strictEqual(message.inspect(), new Buffer('hello world').inspect());
|
||||||
sub2.quit(done);
|
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));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user