# What is the execution sequence when one node has multi wires to other nodes?

**URL:** https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278
**Category:** General
**Created:** [31 May 2022 03:45 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278 "2022-05-31T03:45:49Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![DaisyLoveU](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daisyloveu/32/62406_2.png) [@DaisyLoveU](https://discourse.nodered.org/u/DaisyLoveU)
#### Post date: [31 May 2022 03:45 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/1 "2022-05-31T03:45:49Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/80224581ab7b22ed58c6338190bffb0afa6494d8.png)

I am so confused, like this pic, one input, four wires, what is the order of node 1, 2, 3, 4?

---

<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: [31 May 2022 04:13 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/2 "2022-05-31T04:13:11Z")

</div>

Hi and welcome to the forum.

I don't think there is any order. The message is just sent to the 4 other nodes.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [31 May 2022 05:02 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/3 "2022-05-31T05:02:50Z")

</div>

There is some kind of order, but not in the "normal" way of thinking.

node-red runs on nodejs, which uses an eventloop that is single threaded and handles "events" one by one, so there is a very small delay between each of the messages.

---

<div class="post-metadata">

### Author: ![DaisyLoveU](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daisyloveu/32/62406_2.png) [@DaisyLoveU](https://discourse.nodered.org/u/DaisyLoveU)
#### Post date: [31 May 2022 06:23 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/4 "2022-05-31T06:23:01Z")

</div>

thanks, but as we know, node js is single thread, so there must be a order.  
I guess it depends on the order of the wires. For this, first wire connects node 2, and node 2 log firstly.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7bb89d97d7b015942c31c9e34f447c6d8cf757f4.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e1c469a39ed95fcc4391f236a7ed7fcecfe76da1.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [31 May 2022 06:45 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/5 "2022-05-31T06:45:47Z")

</div>

Hi @DaisyLoveU & welcome to the forum.

> [@DaisyLoveU](#):
>
> I guess it depends on the order of the wires

Yes. But don't rely on that. Instead change your mindset 🙂

For example: what do you really gain by knowing this? It's an implementation detail that doesn't really help that much once you get used to the event based flow paradigm tbh.

My suggestion is to just go with the flow like a twig on the shoulders of a mighty stream. (Sorry I couldn't resist)

Can I ask, are you just trying out node-red or do you have a project in mind? We can certainly help with advice if you need it.

---

<div class="post-metadata">

### Author: ![OriolFM](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oriolfm/32/30710_2.png) [@OriolFM](https://discourse.nodered.org/u/OriolFM)
#### Post date: [31 May 2022 07:43 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/6 "2022-05-31T07:43:12Z")

</div>

@DaisyLoveU  
According to my own experience, it all depends on the wiring order. If you wire them in numerical order, the messages will be sent in that same order.

@Steve-Mcl  
I had to inject 200+ messages (in sequence) in an OPC-UA node, each one of them with a particular nodeID, so I could poll it and get everything back. Instead of using so many inject nodes, I used a single inject node, and a subflow with a lot of OPCUA-Item nodes so each of them would add a single nodeID to the polling list. All those nodes were in parallel, arranged by modules, and wired in sequence, so when I convert the resulting array from the poll, all the parameters are arranged in order.

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

I know it is not necessary and that it would work regardless of how I wire them, but I just like to have the object with the parameters ordered by module and theme, since it's easier for a human to debug and follow than if they're just randomly arranged:

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

---

<div class="post-metadata">

### Author: ![DaisyLoveU](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daisyloveu/32/62406_2.png) [@DaisyLoveU](https://discourse.nodered.org/u/DaisyLoveU)
#### Post date: [31 May 2022 07:53 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/7 "2022-05-31T07:53:58Z")

</div>

Thanks a lot for ur answer, it really helps me learn the deep principle of Node-red!

---

<div class="post-metadata">

### Author: ![OriolFM](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oriolfm/32/30710_2.png) [@OriolFM](https://discourse.nodered.org/u/OriolFM)
#### Post date: [31 May 2022 08:00 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/8 "2022-05-31T08:00:31Z")

</div>

As @Steve-Mcl pointed out, it is usually irrelevant because nodes are triggered when a message comes and not earlier.

However, if you have a use case similar to the one I mentioned, where you need a lot of messages arriving in a short period of time to a node (for configuration, for instance), knowing this comes in handy because you can just wire everything in parallel and sequentially, and node-red will process the input one after the other in its main loop, with no delays in between.

---

<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: [14 June 2022 08:00 UTC](https://discourse.nodered.org/t/what-is-the-execution-sequence-when-one-node-has-multi-wires-to-other-nodes/63278/9 "2022-06-14T08:00:52Z")

</div>

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