From 44526402dc71166d05c839b8044f91c47292c13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=A7=E9=A3=8E?= Date: Wed, 27 Mar 2013 15:58:50 +0800 Subject: [PATCH] fix bug when callback is undefined --- index.js | 2 +- test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 283c743fb1..bdfb9a5130 100644 --- a/index.js +++ b/index.js @@ -710,7 +710,7 @@ RedisClient.prototype.send_command = function (command, args, callback) { if (command === 'set' || command === 'setex') { if(args[args.length - 1] === undefined || args[args.length - 1] === null) { var err = new Error('send_command: ' + command + ' value must not be undefined or null'); - return callback(err); + return callback && callback(err); } } diff --git a/test.js b/test.js index 29fd567880..65561e34a4 100644 --- a/test.js +++ b/test.js @@ -1780,6 +1780,8 @@ tests.OPTIONAL_CALLBACK_UNDEFINED = function () { client.del("op_cb2"); client.set("op_cb2", "y", undefined); client.get("op_cb2", last(name, require_string("y", name))); + + client.set("op_cb_undefined", undefined, undefined); }; tests.ENABLE_OFFLINE_QUEUE_TRUE = function () {