From b0e9dbb929d070547b625849234af39d1d3c9ae0 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 13 Sep 2013 22:55:16 +0100 Subject: [PATCH] Partial fix for Issue #17 --- nodes/core/58-debug.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nodes/core/58-debug.js b/nodes/core/58-debug.js index ac40d2058..700c34c1c 100644 --- a/nodes/core/58-debug.js +++ b/nodes/core/58-debug.js @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ - + var RED = require("../../red/red"); - + var util = require("util"); var ws = require('ws'); var events = require("events"); @@ -45,7 +45,14 @@ DebugNode.send = function(msg) { if (msg.msg instanceof Error) { msg.msg = msg.msg.toString(); } else if (typeof msg.msg === 'object') { - msg.msg = "(Object) "+JSON.stringify(msg.msg,null,1); + try { + msg.msg = "(Object) "+JSON.stringify(msg.msg,null,1); + } + catch (err) { + console.log(msg.msg); + console.log(err); + msg.msg = "[Error] Can't stringify object with circular reference - see console log."; + } } else if (msg.msg == 0) msg.msg = "0"; for (var i in DebugNode.activeConnections) {