# Abort function without any output

**URL:** <https://discourse.nodered.org/t/abort-function-without-any-output/45978>\
**Category:** General\
**Created:** [20 May 2021 13:04 UTC](https://discourse.nodered.org/t/abort-function-without-any-output/45978 "2021-05-20T13:04:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [20 May 2021 13:04 UTC](https://discourse.nodered.org/t/abort-function-without-any-output/45978/1 "2021-05-20T13:04:38Z")

</div>

Hello  
Is it possible to abort a flow during the run in a function with a certain If Then condition so that no payloads or other things are output? The function should then behave absolutely calmly as if nothing had happened.  
I have only found the possibility that the function has 2 outputs and I let the second output run into nothing with the If Then condition.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 May 2021 13:19 UTC](https://discourse.nodered.org/t/abort-function-without-any-output/45978/2 "2021-05-20T13:19:55Z")

</div>

If you are in a Function node then `return null` will not send a message. A common pattern that I use is

```auto
if (some condition) {
  msg = null
} else {
  do normal stuff
}
return msg

```

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [20 May 2021 13:24 UTC](https://discourse.nodered.org/t/abort-function-without-any-output/45978/3 "2021-05-20T13:24:49Z")

</div>

THX  
that makes live easy

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 May 2021 13:48 UTC](https://discourse.nodered.org/t/abort-function-without-any-output/45978/4 "2021-05-20T13:48:37Z")

</div>

If you are not already in a function node then you can use a Switch node that checks the state and only passes good messages through. So for example is you only wanted messages where the payload is 1 then configure it like

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33802f97c5b39be828a89889683b760fc38682d9.png)

Any other messages will be dropped.

---

<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:** [3 June 2021 13:49 UTC](https://discourse.nodered.org/t/abort-function-without-any-output/45978/5 "2021-06-03T13:49:25Z")

</div>

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