# How to Stop a function node from execution its following code?

**URL:** https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828
**Category:** General
**Created:** [9 January 2021 09:44 UTC](https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828 "2021-01-09T09:44:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![nicedevil](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nicedevil](https://discourse.nodered.org/u/nicedevil)
#### Post date: [9 January 2021 09:44 UTC](https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828/1 "2021-01-09T09:44:48Z")

</div>

Heya,

I want to stop a function node from executing its code if a payload is f.e. not a number.  
Is there anything like "node.stop" or "node.break"?

I can't filter this in a node beforehand because there are more messages from other MQTT devices are going into.

Thank you in advance.

---

<div class="post-metadata">

### Author: ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)
#### Post date: [9 January 2021 09:45 UTC](https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828/2 "2021-01-09T09:45:45Z")

</div>

Look for Q-gate in the library!  
 ![Opera Snapshot_2021-01-09_094629_discourse.nodered.org](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/0200b1723c591bb28a0b8f134955cd11bddd6c44.png)

---

<div class="post-metadata">

### Author: ![nicedevil](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nicedevil](https://discourse.nodered.org/u/nicedevil)
#### Post date: [9 January 2021 09:52 UTC](https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828/3 "2021-01-09T09:52:12Z")

</div>

@ghayne thank you, but I think for just this "small feature" I don't wanna add a new package/plugin.

If nothing is available for just "stopping" a function node from executing its code I will return a message with just "null". Thougth there would be an "recommended" way then doing this

---

<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: [9 January 2021 09:54 UTC](https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828/4 "2021-01-09T09:54:13Z")

</div>

Returning null does exactly that. Nothing is passed on. That is the recommended method.

```
if ( isNaN(msg.payload)) { return null; }
```

---

<div class="post-metadata">

### Author: ![nicedevil](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nicedevil](https://discourse.nodered.org/u/nicedevil)
#### Post date: [9 January 2021 09:55 UTC](https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828/5 "2021-01-09T09:55:07Z")

</div>

haha, thank you 😃

---

<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: [23 January 2021 09:55 UTC](https://discourse.nodered.org/t/how-to-stop-a-function-node-from-execution-its-following-code/38828/6 "2021-01-23T09:55:34Z")

</div>

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