# Func-Exec node - NodeRed Crash

**URL:** https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929
**Category:** General
**Created:** [28 October 2020 06:20 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929 "2020-10-28T06:20:25Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)
#### Post date: [28 October 2020 06:20 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/1 "2020-10-28T06:20:25Z")

</div>

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.

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

### Author: ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)
#### Post date: [28 October 2020 07:08 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/2 "2020-10-28T07:08:03Z")

</div>

**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)

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [28 October 2020 07:12 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/3 "2020-10-28T07:12:10Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)
#### Post date: [28 October 2020 07:16 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/4 "2020-10-28T07:16:50Z")

</div>

**Trying\_to\_learn** , you're right, I forgot to specify. Sorry about that.

> **[node-red-contrib-func-exec](https://flows.nodered.org/node/node-red-contrib-func-exec)**
>
> The executable context node which allows you to execute your functions in javascript block.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [28 October 2020 07:40 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/5 "2020-10-28T07:40:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)
#### Post date: [28 October 2020 07:52 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/6 "2020-10-28T07:52:51Z")

</div>

I just opened. I hope I get an answer.

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [28 October 2020 08:30 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/7 "2020-10-28T08:30:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)
#### Post date: [28 October 2020 08:58 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/8 "2020-10-28T08:58:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [28 October 2020 09:14 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/9 "2020-10-28T09:14:06Z")

</div>

Umm the built in exec node has three outputs:  
 ![Screen Shot 2020-10-28 at 5.13.31 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/eb05ddf4aa8a5d8b040dfd89210dffe19207b535.png)

---

<div class="post-metadata">

### Author: ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)
#### Post date: [28 October 2020 09:19 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/10 "2020-10-28T09:19:19Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [27 December 2020 09:19 UTC](https://discourse.nodered.org/t/func-exec-node-nodered-crash/34929/11 "2020-12-27T09:19:22Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
