lorenwest / node-red-contrib-state

Node-RED shared logical state with persistence, notification, and history
MIT License
7 stars 6 forks source link

Fixed an "undefined" when reading ps from history and there isn't any… #12

Closed colincoder closed 2 years ago

colincoder commented 2 years ago

…. Happens on an initial attempt to write the state file and no state has yet been established. Just found this issue when applying 1.6.0 to a new project. The original code to see if ts was in the history fails because no history is yet defined. I rewrote it to make sure all parents of ts were defined before attempting to use its value. This is related to the recent improvement you made to allow file writing frequency to be controllable. Typical error statements on NR startup:

9 Jan 15:41:08 - [error] [shared-state:Water] Error writing state file: /home/pi/.node-red/shared-state/Water
9 Jan 15:41:08 - [error] [shared-state:Water] TypeError: Cannot read property 'ts' of undefined
lorenwest commented 2 years ago

Thanks for the improvement. Published as 1.6.1.