# Weird things happening with \`node.status\`

**URL:** <https://discourse.nodered.org/t/weird-things-happening-with-node-status/81670>\
**Category:** General\
**Created:** [29 September 2023 11:00 UTC](https://discourse.nodered.org/t/weird-things-happening-with-node-status/81670 "2023-09-29T11:00:10Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [29 September 2023 11:00 UTC](https://discourse.nodered.org/t/weird-things-happening-with-node-status/81670/1 "2023-09-29T11:00:10Z")

</div>

(Yes, I've been in a similar place before.)

I think this is different.

## Prelude:

I have a `function` node that is receiving two messages and creating a new message when the two other messages are received.

To _help_ me with seeing what is going on I use the `node.status({})` command.  
The **idea** is that when _message 1_ is received the node indicates that.  
Then when _message 2_ is received, the node also indicates this.

YES! There is a problem with this.  
As both messages arrive at the same time (basically speaking) I only see one message.

So to get around this I delayed one of the messages a few seconds.

Given the messages are coming through every 20 seconds, it is not a big deal.

So I set a 3 second delay.

So I'd expect to see (badly worded)  
_message 1 received_. 3 seconds later _message 2 received_. 17 seconds.  
_message 1 received_. 3 seconds later _message 2 received_. 17 seconds.

No.  
The only way I can get it to do this (with the changes in time understood as being in the equation)  
_message 1 received_. **5** seconds later. _message 2 received_. 15 seconds.  
(repeat)

The messages are _complicated_ but not impossible.  
Here are two examples of the messages.

`{"payload":{"Who":"TimePi","device":"Modem","Modem":"Online"},"_msgid":"166050d1d44749f4"}`  
`{"payload":{"Who":"TimePi","device":"UpLink","UpLink":"Online"},"_msgid":"570805fe17dd94e5"}`

They are sent in _together_ but with a `5` second difference between then.

This is the node:

```auto
[{"id":"4bccf388.5f0814","type":"function","z":"c636aa5a.cc34","name":"Make ONE message","func":"let A;\nlet B;\nlet C;\nlet D = context.get(\"D\") || 0;\nlet E = context.get(\"E\") || 0;\nif (msg.topic == \"NEWDAY\")\n{\n return msg;\n}\n\nif (msg.payload.device == \"Modem\")\n{\n //\n // Modem detected.\n //\n// node.warn(\"Modem message arrived\");\n// node.warn(msg.condition);\n context.set(\"Modem\",1)\n context.set(\"Modem_status\",msg.payload.Modem);\n context.set(\"WHO\",msg.payload.Who);\n node.status({ fill: \"green\", text: \"Modem\" });\n}\nif (msg.payload.device == \"UpLink\")\n{\n //\n // UpLink detected.\n //\n// node.warn(\"UpLink message arrived\");\n// node.warn(msg.condition);\n context.set(\"UpLink\",1)\n context.set(\"UpLink_status\",msg.payload.UpLink);\n context.set(\"WHO\",msg.payload.Who);\n node.status({ fill: \"red\", text: \"Uplink\" });\n}\n\n//node.status({});\n\n//if ((context.get(\"Modem\") == 1) && (context.get(\"Uplink\") == 1))\nif (context.get(\"Modem\") == 1)\n{\n //\n if (context.get(\"UpLink\") == 1)\n {\n //\n // both messages received.\n //\n //node.status({fill:\"yellow\",shape:\"dot\",text:\"message\"});\n context.set(\"Modem\",0);\n context.set(\"UpLink\",0);\n A = context.get(\"Modem_status\");\n B = context.get(\"UpLink_status\");\n C = context.get(\"WHO\");\n msg.topic = C;\n //msg.payload = {\"Who\":msg.who,\"Modem\": context.get(\"Modem_status\"), \"Uplink\": context.get(\"UpLink_status\")};\n\n //node.status({});\n \n msg.payload = {\n \"Who\":C,\n \"Modem\": A, \n \"UpLink\": B\n };\n return msg;\n }\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1990,"y":4740,"wires":[["dc8d6eed.9ba1d8","cfb7b905.7a326"]]}]

```

Why doesn't the `node.status` work _nicely_ with ONLY a `5` second difference between the two messages being received?

Other stuff:  
NR 3.0.2  
RasPi 3B+  
Buster

```auto
node -v
v14.19.0

```

Thanks in advance.

---

<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:** [29 September 2023 11:16 UTC](https://discourse.nodered.org/t/weird-things-happening-with-node-status/81670/2 "2023-09-29T11:16:35Z")

</div>

Add node.warn() statements at the point you set the status and see what is going on.

---

<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:** [28 November 2023 11:16 UTC](https://discourse.nodered.org/t/weird-things-happening-with-node-status/81670/3 "2023-11-28T11:16:45Z")

</div>

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