Groov Rio node-red contextStore persistence

Hi Everyone.
I have a Groov Rio running node-red and would like to make my context variables (flow. and global.) persistent through a reset or reboot.

The node red page says I should add the following to my settings.js

contextStorage: {
   default: {
       module: "localfilesystem"
   }
}

After making these changes node-red will not start.
The log shows the following:

SyntaxError: Unexpected token 'default'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/lib/node_modules/node-red/red.js:136:20)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
Error loading settings file: /usr/share/nxtio/services/node-red/settings.js
/usr/share/nxtio/services/node-red/settings.js:219
default: {
^^^^^^^ 

Node-RED version 2.2.2
Node.js version v12.22.1
System Version 3.4.0-b.22

Any feedback would be appreciated.

Thanks

Steve

I’m going to have to test it here, I’m thinking the RIO is not going have the permissions to write the context files in that location.
That said, it looks like the error is more about the formatting of the settings.js file.
Did you double check the indenting? @torchard gave some hints on that…
Look at the last few posts here: Change Editor Theme

Also be aware that a firmware update will blow away those context files, so you will need to back them up and restore them when you update firmware.
Power cycle (or simple reset) should be fine assuming it can write the context files.

@sbaird welcome to the forums!

When adding to the settings.js file you will need to make sure that you put new objects inside the module.exports brackets with a comma at the end of the previous object. Here’s a screenshot of how I modified my settings file, after adding this I was able to restart Node-RED.

And just to confirm my question about write permissions, its not a problem.
@torchard and I did a quick Hello World test with a global.payload and it worked as expected. (We rebooted his RIO and the payload loaded as expected).

Thanks folks, works great.

Update:
This worked for a couple or resets and at least three power cycles. Now node-red will not start with the following console log output:

Welcome to Node-RED

===================

16 Aug 17:44:54 - [info] Node-RED version: v2.2.2

16 Aug 17:44:54 - [info] Node.js version: v12.22.1

16 Aug 17:44:54 - [info] Linux 4.19.37-rt19-g3f943915b5 arm LE

16 Aug 17:45:00 - [info] Loading palette nodes

16 Aug 17:45:22 - [info] Dashboard version 3.1.7 started at /node-red/ui

16 Aug 17:45:22 - [info] Settings file : /usr/share/nxtio/services/node-red/settings.js

16 Aug 17:45:22 - [warn] Use of httpRoot is DEPRECATED. Use httpNodeRoot/httpAdminRoot instead

16 Aug 17:45:22 - [info] Context store : 'default' [module=localfilesystem]

16 Aug 17:45:22 - [error] Failed to start server:

16 Aug 17:45:22 - [error] Error: Error loading context store: Error: Invalid JSON in context file '/home/dev/.node-red/context/e63fc28d657447f9/flow.json'

at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/context/index.js:180:15

i tried to access /home/dev/.node-red/context/e63fc28d657447f9/flow.json using VI from SSH. the file does no appear to exist.

Steve

You can get that error if you write some malformed JSON to context or you manage to power cycle just before the context is written (this is not an Opto issue, but the way Node-RED writes context files).
I’d delete the .node-red/context directory totally and see if that gets you back up and running.

ok that worked. any idea when Opto will fix this?
Thanks

Opto has done some code submissions for Node-RED, but its unlikely we are going to wade in on this one. The Node-RED guys seem to have it in hand… best to leave it there.
Lastly, shell modifications are unsupported, there are just too many variables at play.