1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Prevent event thread contention when sending to Debug node

Closes #1311
This commit is contained in:
Nick O'Leary 2017-07-01 22:01:56 +01:00
parent 6db2c04585
commit 6201ed4d55
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -29,7 +29,9 @@ module.exports = function(RED) {
node.log("\n"+util.inspect(msg, {colors:useColors, depth:10}));
}
if (this.active) {
sendDebug({id:this.id,name:this.name,topic:msg.topic,msg:msg,_path:msg._path});
setTimeout(function() {
sendDebug({id:node.id,name:node.name,topic:msg.topic,msg:msg,_path:msg._path});
},0);
}
} else {
// debug user defined msg property
@ -53,7 +55,9 @@ module.exports = function(RED) {
}
}
if (this.active) {
sendDebug({id:this.id,z:this.z,name:this.name,topic:msg.topic,property:property,msg:output,_path:msg._path});
setTimeout(function() {
sendDebug({id:node.id,z:node.z,name:node.name,topic:msg.topic,property:property,msg:output,_path:msg._path});
},0);
}
}
});
@ -178,7 +182,9 @@ module.exports = function(RED) {
DebugNode.logHandler = new events.EventEmitter();
DebugNode.logHandler.on("log",function(msg) {
if (msg.level === RED.log.WARN || msg.level === RED.log.ERROR) {
setTimeout(function() {
sendDebug(msg);
},0);
}
});
RED.log.addHandler(DebugNode.logHandler);