@node-red/runtime 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/flows/util.js +1 -0
- package/lib/nodes/Node.js +64 -1
- package/package.json +4 -4
package/lib/flows/util.js
CHANGED
|
@@ -83,6 +83,7 @@ function createNode(flow,config) {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
try {
|
|
86
|
+
Object.defineProperty(conf,'_module', {value: typeRegistry.getNodeInfo(type), enumerable: false, writable: true })
|
|
86
87
|
Object.defineProperty(conf,'_flow', {value: flow, enumerable: false, writable: true })
|
|
87
88
|
newNode = new nodeTypeConstructor(conf);
|
|
88
89
|
} catch (err) {
|
package/lib/nodes/Node.js
CHANGED
|
@@ -59,6 +59,9 @@ function Node(n) {
|
|
|
59
59
|
// which we can tolerate as they are the same object.
|
|
60
60
|
Object.defineProperty(this,'_flow', {value: n._flow, enumerable: false, writable: true })
|
|
61
61
|
}
|
|
62
|
+
if (n._module) {
|
|
63
|
+
Object.defineProperty(this,'_module', {value: n._module, enumerable: false, writable: true })
|
|
64
|
+
}
|
|
62
65
|
this.updateWires(n.wires);
|
|
63
66
|
}
|
|
64
67
|
|
|
@@ -496,7 +499,12 @@ function log_helper(self, level, msg) {
|
|
|
496
499
|
if (self.name) {
|
|
497
500
|
o.name = self.name;
|
|
498
501
|
}
|
|
499
|
-
|
|
502
|
+
// See https://github.com/node-red/node-red/issues/3327
|
|
503
|
+
try {
|
|
504
|
+
self._flow.log(o);
|
|
505
|
+
} catch(err) {
|
|
506
|
+
logUnexpectedError(self, err)
|
|
507
|
+
}
|
|
500
508
|
}
|
|
501
509
|
/**
|
|
502
510
|
* Log an INFO level message
|
|
@@ -576,4 +584,59 @@ Node.prototype.status = function(status) {
|
|
|
576
584
|
this._flow.handleStatus(this,status);
|
|
577
585
|
};
|
|
578
586
|
|
|
587
|
+
|
|
588
|
+
function inspectObject(flow) {
|
|
589
|
+
try {
|
|
590
|
+
let properties = new Set()
|
|
591
|
+
let currentObj = flow
|
|
592
|
+
do {
|
|
593
|
+
if (!Object.getPrototypeOf(currentObj)) { break }
|
|
594
|
+
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item))
|
|
595
|
+
} while ((currentObj = Object.getPrototypeOf(currentObj)))
|
|
596
|
+
let propList = [...properties.keys()].map(item => `${item}[${(typeof flow[item])[0]}]`)
|
|
597
|
+
propList.sort();
|
|
598
|
+
let result = [];
|
|
599
|
+
let line = "";
|
|
600
|
+
while (propList.length > 0) {
|
|
601
|
+
let prop = propList.shift()
|
|
602
|
+
if (line.length+prop.length > 80) {
|
|
603
|
+
result.push(line)
|
|
604
|
+
line = "";
|
|
605
|
+
} else {
|
|
606
|
+
line += " "+prop
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (line.length > 0) {
|
|
610
|
+
result.push(line);
|
|
611
|
+
}
|
|
612
|
+
return result.join("\n ")
|
|
613
|
+
|
|
614
|
+
} catch(err) {
|
|
615
|
+
return "Failed to capture object properties: "+err.toString()
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function logUnexpectedError(node, error) {
|
|
620
|
+
let moduleInfo = node._module?`${node._module.module}@${node._module.version}`:"undefined"
|
|
621
|
+
Log.error(`
|
|
622
|
+
********************************************************************
|
|
623
|
+
Unexpected Node Error
|
|
624
|
+
${error.stack}
|
|
625
|
+
Node:
|
|
626
|
+
Type: ${node.type}
|
|
627
|
+
Module: ${moduleInfo}
|
|
628
|
+
ID: ${node._alias||node.id}
|
|
629
|
+
Properties:
|
|
630
|
+
${inspectObject(node)}
|
|
631
|
+
Flow: ${node._flow?node._flow.path:'undefined'}
|
|
632
|
+
Type: ${node._flow?node._flow.TYPE:'undefined'}
|
|
633
|
+
Properties:
|
|
634
|
+
${node._flow?inspectObject(node._flow):'undefined'}
|
|
635
|
+
|
|
636
|
+
Please report this issue, including the information logged above:
|
|
637
|
+
https://github.com/node-red/node-red/issues/
|
|
638
|
+
********************************************************************
|
|
639
|
+
`)
|
|
640
|
+
}
|
|
641
|
+
|
|
579
642
|
module.exports = Node;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-red/runtime",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@node-red/registry": "2.1.
|
|
20
|
-
"@node-red/util": "2.1.
|
|
19
|
+
"@node-red/registry": "2.1.5",
|
|
20
|
+
"@node-red/util": "2.1.5",
|
|
21
21
|
"async-mutex": "0.3.2",
|
|
22
22
|
"clone": "2.1.2",
|
|
23
|
-
"express": "4.17.
|
|
23
|
+
"express": "4.17.2",
|
|
24
24
|
"fs-extra": "10.0.0",
|
|
25
25
|
"json-stringify-safe": "5.0.1"
|
|
26
26
|
}
|