@node-red/runtime 2.1.2 → 2.2.0-beta.1

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/Flow.js CHANGED
@@ -439,8 +439,6 @@ class Flow {
439
439
  }
440
440
  }
441
441
  return [env.name, env];
442
-
443
- return [env.name, env];
444
442
  });
445
443
  group._env = Object.fromEntries(entries);
446
444
  }
@@ -457,24 +455,24 @@ class Flow {
457
455
  const val
458
456
  = ((value === "true") ||
459
457
  (value === true));
460
- return {
458
+ return [{
461
459
  val: val
462
- };
460
+ }, null];
463
461
  }
464
462
  if (type === "cred") {
465
- return {
463
+ return [{
466
464
  val: value
467
- };
465
+ }, null];
468
466
  }
469
467
  try {
470
468
  var val = redUtil.evaluateNodeProperty(value, type, node, null, null);
471
- return {
469
+ return [{
472
470
  val: val
473
- };
471
+ }, null];
474
472
  }
475
473
  catch (e) {
476
474
  this.error(e);
477
- return null;
475
+ return [null, null];
478
476
  }
479
477
  }
480
478
  }
@@ -488,7 +486,7 @@ class Flow {
488
486
  return this.getGroupEnvSetting(node, parent, name);
489
487
  }
490
488
  }
491
- return null;
489
+ return [null, name];
492
490
  }
493
491
 
494
492
 
@@ -545,6 +543,9 @@ class Flow {
545
543
  }
546
544
  }
547
545
  }
546
+ else {
547
+ key = key.substring(8);
548
+ }
548
549
  }
549
550
  return this.parent.getSetting(key);
550
551
  }
@@ -373,10 +373,11 @@ class Subflow extends Flow {
373
373
  const node = this.subflowInstance;
374
374
  if (node.g) {
375
375
  const group = this.getGroupNode(node.g);
376
- const result = this.getGroupEnvSetting(node, group, name);
376
+ const [result, newName] = this.getGroupEnvSetting(node, group, name);
377
377
  if (result) {
378
378
  return result.val;
379
379
  }
380
+ name = newName;
380
381
  }
381
382
 
382
383
 
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
- self._flow.log(o);
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.2",
3
+ "version": "2.2.0-beta.1",
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.2",
20
- "@node-red/util": "2.1.2",
19
+ "@node-red/registry": "2.2.0-beta.1",
20
+ "@node-red/util": "2.2.0-beta.1",
21
21
  "async-mutex": "0.3.2",
22
22
  "clone": "2.1.2",
23
- "express": "4.17.1",
23
+ "express": "4.17.2",
24
24
  "fs-extra": "10.0.0",
25
25
  "json-stringify-safe": "5.0.1"
26
26
  }