# Confusing error

**URL:** https://discourse.nodered.org/t/confusing-error/12147
**Category:** General
**Created:** [12 June 2019 21:34 UTC](https://discourse.nodered.org/t/confusing-error/12147 "2019-06-12T21:34:04Z")
**Posts on this page:** 20
**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: [12 June 2019 21:34 UTC](https://discourse.nodered.org/t/confusing-error/12147/1 "2019-06-12T21:34:05Z")

</div>

I am getting an error in a flow.

```auto
{"message":"ReferenceError: IP_Address is not defined (line 3, col 60)","source":{"id":"ee68941a.7bad58","type":"function","name":"TimeStamp","count":1}}

```

Note: line 3 column 60

Entering `ee68941a.7bad58` into the search I get a node. `function` called `TimeStamp`.  
That bit is good.

But....

This is the code from said node:

```auto
var time = new Date().toLocaleString();
//msg.payload = time + " Test message";
//node.warn(msg.payload.WIFI_DEVICE);
msg.payload = time + " " + msg.payload.IP_Address + " >" + msg.payload.WIFI_DEVICE + "<";
msg.time = time;
return msg;

```

Line 3 is a remark.

Putting that aside, and looking at line 4 (column 60)  
That isn't right either.

Can someone help me work out where this error is?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [12 June 2019 23:44 UTC](https://discourse.nodered.org/t/confusing-error/12147/2 "2019-06-12T23:44:24Z")

</div>

Put a debug node on the output of the node feeding the function node and have it display the `complete msg object` then you can see if `msg.payload.IP_Address` exists coming into the function node.

---

<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: [13 June 2019 06:28 UTC](https://discourse.nodered.org/t/confusing-error/12147/3 "2019-06-13T06:28:59Z")

</div>

I'm waiting for the _bug_ to again stick his/their head up.

😴

---

<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: [13 June 2019 20:55 UTC](https://discourse.nodered.org/t/confusing-error/12147/4 "2019-06-13T20:55:13Z")

</div>

I hope this is it:

```auto
{"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"6ec38677.69fe88","time":"2019-6-13 15:40:39","ttl":0,"_queuetimestamp":1560404439925,"_queueCount":3}
{"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"6a3faeb1.cb12","time":"2019-6-13 15:40:42","ttl":0,"_queuetimestamp":1560404442423,"_queueCount":2}
{"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"912ba1fe.22654","time":"2019-6-14 05:39:16","ttl":0,"_queuetimestamp":1560454756656,"_queueCount":1}
{"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"6f20281d.e8e578","time":"2019-6-14 05:39:21","ttl":0,"_queuetimestamp":1560454761191,"_queueCount":0}

```

I am tracking a few _problems_ with WiFi, connections, etc.  
I have log files coming out of.... (well, you get the rest) I don't know why but something is going on.

I got those lines from the "RAW IFF" file which just logs the IFF messages coming in.  
(As you suggested)  
Then they go through the other nodes and get saved as something _useful_ to me.

To help myself I also inject a _MARK_ here and there which is basically a line with the date/time so if I am looking for something I can section it off with respect to the mark.

Strangely those 4 messages didn't make it through to the rest of the nodes.

But look at this picture and I hope it helps also with what is going on.

 ![Screenshot%20from%202019-06-14%2006-51-17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b7f3a2d503bc7a4b96ed4ad35363a27c6835be47.png)

And this is the suspect node code:

```auto
var time = new Date().toLocaleString();
//msg.payload = time + " Test message";
//node.warn(msg.payload.WIFI_DEVICE);
msg.payload = time + " " + msg.payload.IP_Address + " >" + msg.payload.WIFI_DEVICE + "<";
msg.time = time;
return msg;

```

Or maybe this one:

```auto
if (msg.topic == "TIMESTAMP")
{
    return msg;
}
var time_ = new Date().toLocaleString();
var WIFI_DEVICE = msg.payload.WIFI_DEVICE;
var IP_ = msg.payload.IP_Address;

node.warn(WIFI_DEVICE);
node.warn(IP_Address);

msg = {payload:time_ + " " + WIFI_DEVICE + " " + IP_};
return msg;

```

It is early morning and I just got up.  
(Poor excuse but....)

(Typically it will be something easy and I just missed it.)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [13 June 2019 21:03 UTC](https://discourse.nodered.org/t/confusing-error/12147/5 "2019-06-13T21:03:03Z")

</div>

```auto
if (msg.topic == "TIMESTAMP")
{
    return msg;
}
var time_ = new Date().toLocaleString();
var WIFI_DEVICE = msg.payload.WIFI_DEVICE;
var IP_ = msg.payload.IP_Address;
msg = {payload:time_ + " " + WIFI_DEVICE + " " + IP_};
return msg;

```

this code will not process any of those messages since the topics do not match

---

<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: [13 June 2019 21:16 UTC](https://discourse.nodered.org/t/confusing-error/12147/6 "2019-06-13T21:16:33Z")

</div>

Thanks very much.

That has shown/exposed other problems to me.

Good.

Alas I have to scoot now. Other things. New day. Hopefully I will get it worked out tonight.

---

<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: [13 June 2019 22:11 UTC](https://discourse.nodered.org/t/confusing-error/12147/7 "2019-06-13T22:11:29Z")

</div>

> [@Trying\_to\_learn](#):
>
> I hope this is it:
> 
> ```auto
> {"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"6ec38677.69fe88","time":"2019-6-13 15:40:39","ttl":0,"_queuetimestamp":1560404439925,"_queueCount":3}
> {"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"6a3faeb1.cb12","time":"2019-6-13 15:40:42","ttl":0,"_queuetimestamp":1560404442423,"_queueCount":2}
> {"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"912ba1fe.22654","time":"2019-6-14 05:39:16","ttl":0,"_queuetimestamp":1560454756656,"_queueCount":1}
> {"topic":"STATUS/WIFIDEVICEID","payload":"{\"WIFI_DEVICE\":\"GPS\",\"IP_Address\":\"192.168.1.4\"}","qos":0,"retain":false,"_msgid":"6f20281d.e8e578","time":"2019-6-14 05:39:21","ttl":0,"_queuetimestamp":1560454761191,"_queueCount":0}
> 
> ```

You realise that payload is a JSON string right? So accessing `msg.payload.IP_Address` won't be possible unless you run it through a JSON node or use JSON.parse() first.

---

<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: [14 June 2019 07:04 UTC](https://discourse.nodered.org/t/confusing-error/12147/8 "2019-06-14T07:04:40Z")

</div>

Yes, I pass it through a `JSON` node, but it all goes to pot after that - in other ways.

Thanks.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [14 June 2019 07:30 UTC](https://discourse.nodered.org/t/confusing-error/12147/9 "2019-06-14T07:30:04Z")

</div>

The error message you are trying to track down the cause of is: `ReferenceError: IP_Address is not defined (line 3, col 60)`.

So this means _anywhere_ you have code referencing a variable called `IP_Address` you need to take a closer look to see why it might not be defined.

In a later post, you've shared the following code block:

```auto
if (msg.topic == "TIMESTAMP")
{
    return msg;
}
var time_ = new Date().toLocaleString();
var WIFI_DEVICE = msg.payload.WIFI_DEVICE;
var IP_ = msg.payload.IP_Address;

node.warn(WIFI_DEVICE);
node.warn(IP_Address);

msg = {payload:time_ + " " + WIFI_DEVICE + " " + IP_};
return msg;

```

In this code you do `node.warn(IP_Address);` - but no where in this code have you defined `IP_Address` - so that will be the line of code causing the error message.

A few lines earlier you create a variable called `IP_` set to the value of `msg.payload.IP_Address`. I guess you meant to call that variable `IP_Address`.

---

<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: [14 June 2019 07:34 UTC](https://discourse.nodered.org/t/confusing-error/12147/10 "2019-06-14T07:34:12Z")

</div>

Thanks Nick.

I am closing in on the problem.

This is now what I see/get:

Going into node:

```auto
{"topic":"STATUS/WIFIDEVICEID","payload":"2019-6-14 17:29:11 192.168.1.4 >GPS<","qos":0,"retain":false,"_msgid":"cc5d14d.72050e8","WIFI_DEVICE":"GPS","IP_Address":"192.168.1.4","time":"2019-6-14 17:29:11","_event":"node:ca022be0.ef864"}

```

Node code:

```auto

var time_ = new Date().toLocaleString();
var WIFI_DEVICE = msg.WIFI_DEVICE;
var IP_Address = msg.IP_ADDRESS;

node.warn(" *******");
node.warn(WIFI_DEVICE);
node.warn(" *******");
node.warn(IP_Address);

msg = {payload:time_ + " " + WIFI_DEVICE + " " + IP_Address};
return msg;

```

But `WIFI_DEVICE` is not working.

I'm guessing it is the names tripping over one another.

(Going to try new names but posting to maintain the honesty of what is happening.)

Yeah, ok. Seems the names were a problem.

Now back to the other problem pointed out to me earlier today by Zenofmud.

---

<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: [14 June 2019 08:06 UTC](https://discourse.nodered.org/t/confusing-error/12147/11 "2019-06-14T08:06:00Z")

</div>

All:

Thanks.

Found a few more _bugs_. I really hope that I have learnt my lesson on most (if not all) of them.

What caught me a few times was a missing `ELSE` as mentioned by Zenofmud.

That is what happens when you bash code into a node way after making the node.

Other _silly_ mistakes which I shall have to accept as part of learning.

All seems to now be working.

Now back to chasing the original problem about erroneous messages from a WiFi device.

---

<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: [15 June 2019 10:05 UTC](https://discourse.nodered.org/t/confusing-error/12147/12 "2019-06-15T10:05:33Z")

</div>

Part 2:

Though I hope not related to the original problem, I am (again) getting weird error messages.

I have parts of the flows catching the errors and queuing them for me to see.

I look at the message and see this:

 ![Screenshot%20from%202019-06-15%2019-51-31](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/cc3fb53424f66cdc54547fd3178cd4b595433dc2.png)

_Clearly_ saying it is WiFi Scanner flow.

Going to said flow I see nothing.  
This is a quick picture of the flow. Note the queue is empty.

 ![Screenshot%20from%202019-06-15%2019-53-34](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d70112d8783263b05a2212e63cb42bed154fef2f.png)

But then, going back to the first screen, You can see a list of flows and "Telemetry" has a blue light beside it.  
That means there is a captured error on that flow.

Going there I see this:

 ![Screenshot%20from%202019-06-15%2019-57-56](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/98a158bd91b39609e719b4ba4215581b2ac6619a.png)

Following that node I get to this:

 ![Screenshot%20from%202019-06-15%2020-00-38](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d17515a641a47754b2700cc84655c4b51865081d.png)

Well, when I look at it the `"` is the 23rd letter of line 19, but I won't hold that as a problem.

But what I am not understanding is: Is there a problem?  
I've checked the syntax and as best I can see it is ok.

Why is it saying it is in "WiFI Scanner Flow" when the error is in Telemetry?

---

<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: [15 June 2019 10:11 UTC](https://discourse.nodered.org/t/confusing-error/12147/13 "2019-06-15T10:11:50Z")

</div>

Are you certain you are looking at the correct function node?

Copy the `id` from the error and use search (ctrl+f) and double check you're looking at the right node.

It looks like it's coming from a function node named `test`

---

<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: [15 June 2019 10:15 UTC](https://discourse.nodered.org/t/confusing-error/12147/14 "2019-06-15T10:15:21Z")

</div>

Yes I am certain.

That is what I did.

I got the ID (78e95481.ea2e84) searched it and that node flashed.  
Ok, I didn't show the screen shot of that, but I opened it up and showed the code.

 ![Screenshot%20from%202019-06-15%2020-17-35](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/61e4101f5df65b6e4e3ed8c438da38021f91dfd3.png)

---

<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: [15 June 2019 10:27 UTC](https://discourse.nodered.org/t/confusing-error/12147/15 "2019-06-15T10:27:54Z")

</div>

If you disconnect the node's input and feed it `false` with an inject node does it give that error? If so then export the node so we can try it. I can only think the quotes are mixed up for some reason, but can't see anything.

---

<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: [15 June 2019 10:32 UTC](https://discourse.nodered.org/t/confusing-error/12147/16 "2019-06-15T10:32:49Z")

</div>

Just did it.

Injected `false` and no error.

---

<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: [15 June 2019 11:04 UTC](https://discourse.nodered.org/t/confusing-error/12147/17 "2019-06-15T11:04:15Z")

</div>

> [@Colin](#):
>
> I can only think the quotes are mixed up for some reason, but can't see anything.

I was looking at that. Thinking maybe it's an extended character (copy paste from somewhere?) rather than a regular double quote?

No harm in simply overtyping the quotes and trying again.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [15 June 2019 11:35 UTC](https://discourse.nodered.org/t/confusing-error/12147/18 "2019-06-15T11:35:36Z")

</div>

> [@Trying\_to\_learn](#):
>
> Yes I am certain.
> 
> That is what I did.
> 
> I got the ID (78e95481.ea2e84) searched it and that node flashed

I suggest (on the top of previous good suggestions) adding a status node connected to a debug node (as below). Configure the status node to monitor only the function node under analysis.

I wonder if you will get an "undefined" displayed in the debug panel.

![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c1d237513f1f23f2716c6f970b5d1d57469197ae.png)

What is the Node-RED version in use? You are not using a beta test version, are you?

---

<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: [15 June 2019 21:21 UTC](https://discourse.nodered.org/t/confusing-error/12147/19 "2019-06-15T21:21:39Z")

</div>

Andrie,

NR 0.20.3

I added this. Which is slightly more, but I really want to catch this problem.

```auto
[{"id":"7cd498e9.1a7cc8","type":"function","z":"c636aa5a.cc34","name":"Time stamp","func":"msg.time = new Date().toLocaleString();\nreturn msg;","outputs":1,"noerr":0,"x":3310,"y":3070,"wires":[["36aedb4c.5d6724"]]},{"id":"36aedb4c.5d6724","type":"simple-queue","z":"c636aa5a.cc34","name":"queue1","firstMessageBypass":false,"bypassInterval":"0","x":3530,"y":3070,"wires":[["8608bdfd.9a35a"]]},{"id":"33d25560.bbef52","type":"inject","z":"c636aa5a.cc34","name":"Next","topic":"","payload":"next","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":3360,"y":3130,"wires":[["e3688214.4b1028"]]},{"id":"e3688214.4b1028","type":"change","z":"c636aa5a.cc34","name":"","rules":[{"t":"set","p":"trigger","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3530,"y":3130,"wires":[["36aedb4c.5d6724"]]},{"id":"3db36dc9.0fd7b2","type":"inject","z":"c636aa5a.cc34","name":"Wipe","topic":"","payload":"wipe","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":3360,"y":3170,"wires":[["50c8d2ad.be1484"]]},{"id":"50c8d2ad.be1484","type":"change","z":"c636aa5a.cc34","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":3530,"y":3170,"wires":[["36aedb4c.5d6724"]]},{"id":"8608bdfd.9a35a","type":"debug","z":"c636aa5a.cc34","name":"Test node activity","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3730,"y":3070,"wires":[]},{"id":"4ed206b5.898e4","type":"status","z":"c636aa5a.cc34","name":"","scope":["78e95481.ea2e84"],"x":2850,"y":3020,"wires":[["7cd498e9.1a7cc8"]]}]

```

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [15 June 2019 21:44 UTC](https://discourse.nodered.org/t/confusing-error/12147/20 "2019-06-15T21:44:08Z")

</div>

ok good, and did you try Steve´s suggestion to rewrite the line inside the function node? The error message indicates that the runtime is evaluating what is on the right side of `fill` as `red` instead of `"red"`

[Next page](https://discourse.nodered.org/t/confusing-error/12147.md?page=2)
