Avoid stringify ServerResponse and Socket in Debug node

Fixes #1311
This commit is contained in:
Nick O'Leary 2017-07-03 20:53:20 +01:00
parent c34c98386e
commit b8c80a2310
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 11 additions and 5 deletions

View File

@ -141,11 +141,17 @@ module.exports = function(RED) {
if (value.length > debuglength) {
value = value.substring(0,debuglength)+"...";
}
} else if (value !== null && typeof value === 'object' && value.type === "Buffer") {
value.__encoded__ = true;
value.length = value.data.length;
if (value.length > debuglength) {
value.data = value.data.slice(0,debuglength);
} else if (value && value.constructor) {
if (value.constructor.name === "Buffer") {
value.__encoded__ = true;
value.length = value.data.length;
if (value.length > debuglength) {
value.data = value.data.slice(0,debuglength);
}
} else if (value.constructor.name === "ServerResponse") {
value = "[internal]"
} else if (value.constructor.name === "Socket") {
value = "[internal]"
}
}
return value;