You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Check for stream.writable before trying to write()
This commit is contained in:
7
index.js
7
index.js
@@ -622,6 +622,7 @@ RedisClient.prototype.send_command = function () {
|
|||||||
buffer_args = false;
|
buffer_args = false;
|
||||||
|
|
||||||
elem_count += args.length;
|
elem_count += args.length;
|
||||||
|
// Probably should just scan this like a normal person
|
||||||
buffer_args = args.some(function (arg) {
|
buffer_args = args.some(function (arg) {
|
||||||
// this is clever, but might be slow
|
// this is clever, but might be slow
|
||||||
return arg instanceof Buffer;
|
return arg instanceof Buffer;
|
||||||
@@ -631,6 +632,11 @@ RedisClient.prototype.send_command = function () {
|
|||||||
// This means that using Buffers in commands is going to be slower, so use Strings if you don't need binary.
|
// This means that using Buffers in commands is going to be slower, so use Strings if you don't need binary.
|
||||||
|
|
||||||
command_str = "*" + elem_count + "\r\n$" + command.length + "\r\n" + command + "\r\n";
|
command_str = "*" + elem_count + "\r\n$" + command.length + "\r\n" + command + "\r\n";
|
||||||
|
|
||||||
|
if (! stream.writable && exports.debug_mode) {
|
||||||
|
console.log("send command: stream is not writeable, should get a close event next tick.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (! buffer_args) { // Build up a string and send entire command in one write
|
if (! buffer_args) { // Build up a string and send entire command in one write
|
||||||
for (i = 0, il = args.length, arg; i < il; i += 1) {
|
for (i = 0, il = args.length, arg; i < il; i += 1) {
|
||||||
@@ -643,7 +649,6 @@ RedisClient.prototype.send_command = function () {
|
|||||||
if (exports.debug_mode) {
|
if (exports.debug_mode) {
|
||||||
console.log("send command: " + command_str);
|
console.log("send command: " + command_str);
|
||||||
}
|
}
|
||||||
// Need to catch "Stream is not writable" exception here and error everybody in the command queue out
|
|
||||||
stream.write(command_str);
|
stream.write(command_str);
|
||||||
} else {
|
} else {
|
||||||
if (exports.debug_mode) {
|
if (exports.debug_mode) {
|
||||||
|
Reference in New Issue
Block a user