Func-Exec node - NodeRed Crash

Hello

I encountered a rather strange situation, I don't know if this is normal or if there is a problem in the func-exec.

In other words, I expected the func-exec to generate an error, not to crash the NodeRed. Someone more skilled could enlighten me.

I am attaching a piece of code that generates an error, along with an "equivalent" code that does not generate an error.

[{"id":"a7788d31.9c8a4","type":"func-exec","z":"eb9c06b5.a867d8","name":"Crash NodeRed","func":"var cmd = \"anything\";\n\nvar exec = child_process.exec(cmd, (error, stdout, stderr) => \n{ \n    var time = stdout.split('anything');\n    time = time[1].split('anything');           // This Line Generate NodeRed Crash\n\n    callback(msg);\n});","outputs":1,"noerr":0,"x":640,"y":120,"wires":[["fb8bd387.5dbfe"]]},{"id":"8e535db.0e5732","type":"inject","z":"eb9c06b5.a867d8","name":"Go","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":450,"y":120,"wires":[["a7788d31.9c8a4"]]},{"id":"fb8bd387.5dbfe","type":"debug","z":"eb9c06b5.a867d8","name":"Result 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":120,"wires":[]},{"id":"fe91c7bf.15507","type":"inject","z":"eb9c06b5.a867d8","name":"Go","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":450,"y":200,"wires":[["6a37fb93.a03484"]]},{"id":"46b8c649.555af","type":"debug","z":"eb9c06b5.a867d8","name":"Result 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":200,"wires":[]},{"id":"6a37fb93.a03484","type":"function","z":"eb9c06b5.a867d8","name":"No Crash","func":"var time = 'anything'.split('anything');\ntime = time[1].split('anything');\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":200,"wires":[["46b8c649.555af"]]}]

Tested with :

  • Ubuntu and Windows 10 Pro
  • NodeRed 1.2.2
  • NodeJS 12.19.0

I forgot to add the console log :

TypeError: Cannot read property 'split' of undefined
at evalmachine.:7:20
at ChildProcess.exithandler (child_process.js:315:5)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
28 Oct 09:04:57 - [red] Uncaught Exception:
28 Oct 09:04:57 - TypeError: Cannot read property 'split' of undefined
at evalmachine.:7:20
at ChildProcess.exithandler (child_process.js:315:5)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)

It would seem you are using a non standard node.

It would be nice if you declare that and what its full name is so anyone who may want to help you can load that node before trying to import a flow with a missing node.

Trying_to_learn, you're right, I forgot to specify. Sorry about that.

You should open an incident on the node's GitHub page.

I just opened. I hope I get an answer.

What does that buy you over the built in exec node ?

Compared to built in exec node, it's (somewhat) more customizable :

  • can have several outputs (success on one output, fail on another output). I save another node (function), where I should test this.
  • I can add a node.status with various information (more practical for me sometimes than debug or console).

In my case, it's a matter of habit, I suppose.

Umm the built in exec node has three outputs:
Screen Shot 2020-10-28 at 5.13.31 AM

Indeed, it is. But these three outputs are standard outputs, they cannot be modified/customized.
As I said, in my case it's just a matter of habit.