# Filter node throwing errors when being reset

**URL:** <https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641>\
**Category:** General\
**Created:** [23 May 2023 13:06 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641 "2023-05-23T13:06:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SeRiusRod](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@SeRiusRod](https://discourse.nodered.org/u/SeRiusRod)\
**Post date:** [23 May 2023 13:06 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/1 "2023-05-23T13:06:14Z")

</div>

I have this Filter node that is "filtering" the consumption output from my appliances. It gets the value to filter as a property under payload. And it is configured to distinguish devices by topic.  
 ![imagen](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7e992d5d8b1b2bd98957e6f6a879f337b3fa1495.png)

There's another node/flow that processes devices that publish their consumption on another property.

Every night at 0h, an inject node resets the daily kWh value and resets the filter node to force it to process the first value even if it's the same as the previous.  
 ![imagen](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3bbc40466e7b0dc3c0cdfc61650b6413d08e070b.png)

![imagen](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/279e71cb201ad7ee525dbd28d2dd6f631adfe3f8.png)

But every night at 0h I'm getting two exceptions on the log. One for every flow and filter node.  
I seems like the node is trying to process the reset message and then fails because it doesn't have the configured property.

```auto
23 May 00:00:00 - [error] [rbe:6ccbda17501c01d7] TypeError: Cannot read properties of undefined (reading 'energy_daily_kwh')
    at /usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:430:29
    at Array.reduce (<anonymous>)
    at getObjectProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:429:18)
    at Object.getMessageProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:401:12)
    at RbeNode._inputCallback (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/function/rbe.js:38:34)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
    at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at RbeNode.Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:202:11)
    at RbeNode.Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:186:25)
    at RbeNode.Node.receive (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:485:10)
    at Immediate._onImmediate (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:831:52)
    at processImmediate (node:internal/timers:476:21)
23 May 00:00:00 - [error] [rbe:e01ede74ce12e631] TypeError: Cannot read properties of undefined (reading 'energy_import_kwh')
    at /usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:430:29
    at Array.reduce (<anonymous>)
    at getObjectProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:429:18)
    at Object.getMessageProperty (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:401:12)
    at RbeNode._inputCallback (/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/core/function/rbe.js:38:34)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:210:26
    at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at RbeNode.Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:202:11)
    at RbeNode.Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:186:25)
    at RbeNode.Node.receive (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:485:10)
    at Immediate._onImmediate (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:831:52)
    at processImmediate (node:internal/timers:476:21)

```

Is this normal?

Edit: The switch node before the filter is precisely blocking messages that doesn't have the target property defined.  
 ![imagen](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/5162a4925c13acd677ef7193f6cebf690642fb05.png)

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [23 May 2023 14:24 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/2 "2023-05-23T14:24:01Z")

</div>

It would help to see more of the flow and maybe even be able to import it.  
Why not put a debug node before the filter to see what is coming in.

`is not null` is not the same as "is undefined", right?

Besides, there is another input, maybe that is the way msg come in? Is it disabled all the time?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/aea15fbe34aa825c50d1ed3d6f7f0d2306d3547f.jpeg)

EDIT: Are you sure the error is thrown by that filter node shown above?

---

<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:** [23 May 2023 15:00 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/3 "2023-05-23T15:00:41Z")

</div>

Make sure the reset message has msg.reset set and nothing else (except msg.\_id). Feed it into a debug node and check there is no topic present for example. Perhaps you have left the msg.topic line in the Inject node.

---

<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:** [23 May 2023 15:17 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/4 "2023-05-23T15:17:39Z")

</div>

FYI - we've just merged a fix for the Filter node for the specific error you are hitting - where the property it is configured to monitor is missing from a message.

> <https://github.com/node-red/node-red/pull/4166>
>
> To close #4165
> 
> \<!--
> \## Before you hit that Submit button....
> 
> Please read …our \[contribution guidelines\](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
> before submitting a pull-request.
> 
> \## Types of changes
> 
> What types of changes does your code introduce?
> Put an \`x\` in the boxes that apply
> \--\>
> 
> \- \[x\] Bugfix (non-breaking change which fixes an issue)
> \- \[\] New feature (non-breaking change which adds functionality)
> 
> \<!--
> If you want to raise a pull-request with a new feature, or a refactoring
> of existing code, it \*\*may well get rejected\*\* if it hasn't been discussed on
> the \[forum\](https://discourse.nodered.org) or
> \[slack team\](https://nodered.org/slack) first.
> 
> \--\>
> 
> \## Proposed changes
> 
> 
> This fix check that the required property is present in the msg before trying to process - or rather - it ignores messages where the required property is not present.
> 
> \## Checklist
> 
> 
> \- \[x\] I have read the \[contribution guidelines\](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
> \- \[\] For non-bugfix PRs, I have discussed this change on the forum/slack team.
> \- \[x\] I have run \`grunt\` to verify the unit tests pass
> \- \[\] I have added suitable unit tests to cover the new/changed functionality

---

<div class="post-metadata">

**Author:** ![SeRiusRod](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@SeRiusRod](https://discourse.nodered.org/u/SeRiusRod)\
**Post date:** [24 May 2023 06:46 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/5 "2023-05-24T06:46:49Z")

</div>

Yes, the secondary input is for debugging purposes and it's always disabled.

> [@cameo69](#):
>
> `is not null` is not the same as "is undefined", right?

Yep. I still don't know how to test that an incoming object is present, is defined and has value.  
It would be nice to have a shortcut way in the switch node alongside with the "language" methods.

> [@cameo69](#):
>
> It would help to see more of the flow and maybe even be able to import it.  
> Why not put a debug node before the filter to see what is coming in.

If I gave an export it would mean nothing to you without the incoming data, I think.  
And putting a debug node would be a mess, as this flow receives data from mqtt many times a second. Some devices, like the ones related to PV report every second to be able to manage excess diverting and overload.

---

<div class="post-metadata">

**Author:** ![SeRiusRod](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@SeRiusRod](https://discourse.nodered.org/u/SeRiusRod)\
**Post date:** [24 May 2023 06:49 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/6 "2023-05-24T06:49:49Z")

</div>

Hi Colin.

Nope. Not the case...  
I Should had made the screenshot a little bigger:  
 ![imagen](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/2/d22a4e4d15c172e196ec5a314f5cfb806b117e89.png)

But based on your idea today I tried by not having that change node inline after the reset. But it gave the same exception.

---

<div class="post-metadata">

**Author:** ![SeRiusRod](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@SeRiusRod](https://discourse.nodered.org/u/SeRiusRod)\
**Post date:** [24 May 2023 06:55 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/7 "2023-05-24T06:55:53Z")

</div>

Thanks Nick, That could be my problem.

I've seen that node-red last release was one year ago.  
How I know when this fix is released? Or how I do incorporate it?

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [26 May 2023 17:36 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/8 "2023-05-26T17:36:40Z")

</div>

> [@SeRiusRod](#):
>
> I've seen that node-red last release was one year ago.

At least docker got an update today (26.5.2023).

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 May 2023 20:01 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/9 "2023-05-26T20:01:32Z")

</div>

The fix is also in the latest beta - [🎉 Node-RED 3.1.0-beta.3 released](https://discourse.nodered.org/t/node-red-3-1-0-beta-3-released/78716)

---

<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:** [25 July 2023 20:02 UTC](https://discourse.nodered.org/t/filter-node-throwing-errors-when-being-reset/78641/10 "2023-07-25T20:02:14Z")

</div>

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