# Making flows asynchronous by default

**URL:** <https://discourse.nodered.org/t/making-flows-asynchronous-by-default/14390>\
**Category:** News\
**Created:** [16 August 2019 11:20 UTC](https://discourse.nodered.org/t/making-flows-asynchronous-by-default/14390 "2019-08-16T11:20:30Z")\
**Posts on this page:** 1\
**Showing post:** 77

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [8 September 2019 19:17 UTC](https://discourse.nodered.org/t/making-flows-asynchronous-by-default/14390/77 "2019-09-08T19:17:58Z")

</div>

Updated my home automation system to this latest beta. The update process went very smoothly, just one node type I had to add afterwards (feedparse)

Everything started fine but shortly after I realized I had some stuff not working. It was my "solution" for keeping track of system statuses. Took some while until I found the reason why I was punished...

I had the following typical code in some function nodes:

```auto
if (msg.method === "turnon"){
    msg.payload = "carport turnon";
    node.send(msg);
    msg.payload = "facade entrance turnon";
    node.send(msg);
    msg.payload = "facade washroom turnon";
    node.send(msg);
    msg.payload = "facade garden turnon";
    node.send(msg);
}
if (msg.method === "turnoff"){
    msg.payload = "carport turnoff";
    node.send(msg);
    msg.payload = "facade entrance turnoff";
    node.send(msg);
    msg.payload = "facade washroom turnoff";
    node.send(msg);
    msg.payload = "facade garden turnoff";
    node.send(msg);
}

```

This did work fine in the old version but not in the new. I modified the code like this and now everything looks ok. I assume this is a typical example of the difference, when asynchronous the msg.payload is updated faster and BEFORE all node.send commands have had enough time to be executed. Somehow.

```auto
if (msg.method === "turnon"){
    node.send({ payload:"facade washroom turnon" });
    node.send({ payload:"carport turnon" });
    node.send({ payload:"facade entrance turnon" });
    node.send({ payload:"facade garden turnon" });
}
if (msg.method === "turnoff"){
    node.send({ payload:"facade washroom turnoff" });
    node.send({ payload:"carport turnoff" });
    node.send({ payload:"facade entrance turnoff" });
    node.send({ payload:"facade garden turnoff" });
}

```

---

_[View the full topic](https://discourse.nodered.org/t/making-flows-asynchronous-by-default/14390)._
