Problems understanding and implementing Persistent Storage

Also, since JavaScript passes objects by reference, if something "clears" that object out before the write occurs, it will write the changed value - depending on the life cycle of the variable, that may well be an empty object.

The test to make is - write something you know can never be externally affected e.g...

Function 1

const testObject= {
   prop1: 123
   prop2: "check me"
}
global.set('test_value', testObject) 

then reboot and test it...

Function 2

const testObject = global.get('test_value') 
node.warn([ 'What do you see', testObject)

Additionally, as said earlier, you should set the flush time to something sensible (e.g. 30 secs). Flush only occurs when there is something to write. I.e., never change a value, never write to global.

1 Like