Node-Red Crashing Upon a power fault

This night I had a power fault.
After that my node-red does'nt open correctly and crash.
I have no idea about what to do.
I saw a similar old thread and I tried to start in --safe mode node-red. Unfortunately I was not able to enter the editor as node-red halts with a white screen.
The " Unknown context store 'ram' specified" message worried me as I used "ram" since a couple years.

roberto@RCORE:~ $ node-red-start --safe

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.1.37:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
15 Jul 17:06:21 - [info]
Welcome to Node-RED
===================
15 Jul 17:06:21 - [info] Node-RED version: v4.0.0
15 Jul 17:06:21 - [info] Node.js  version: v20.14.0
15 Jul 17:06:21 - [info] Linux 6.6.31+rpt-rpi-2712 arm64 LE
15 Jul 17:06:21 - [info] Loading palette nodes
15 Jul 17:06:22 - [info] Settings file  : /home/roberto/.node-red/settings.js
15 Jul 17:06:22 - [info] Context store  : 'default' [module=memory]
15 Jul 17:06:22 - [info] User directory : /home/roberto/.node-red
15 Jul 17:06:22 - [info] Projects directory: /home/roberto/.node-red/projects
15 Jul 17:06:22 - [warn] No active project : using default flows file
15 Jul 17:06:22 - [info] Flows file     : /home/roberto/.node-red/flows.json
15 Jul 17:06:22 - [info] Server now running at http://127.0.0.1:1880/
15 Jul 17:06:22 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
15 Jul 17:06:22 - [info] Starting flows
15 Jul 17:06:22 - [info] Started flows
15 Jul 17:06:22 - [info] [zigbee2mqtt-server:CORE] MQTT Connected
15 Jul 17:06:22 - [info] [mqtt-broker:OLL] Connected to broker: mqtt://192.168.1.37:1883
15 Jul 17:06:22 - [info] [alexa-remote-account:alexa] intialising "alexa" with the PROXY method and saved data...
15 Jul 17:06:23 - [info] [zigbee2mqtt-server:CORE] MQTT Subscribed to: "zigbee2mqtt/#
15 Jul 17:06:23 - [warn] Unknown context store 'ram' specified. Using default store.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:BT-LUCI-LETTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PR_SALOTTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PR_SALOTTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TH_MATTEO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_STANZINO-MURO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT-STANZINOINGRESSO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_CUCINA-MURO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_CUCINA-MURO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_UCINA-SOFFITTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW05-CUCINA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:WL_CUCINA-LAVELLO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:WL_CUCINA-LAVELLO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:LU_CUCINA-TERRAZZO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PS_SALOTTO-LIBRERIA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TH_SALOTTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TR_SALOTTO-FINESTRA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TR_SALOTTO-BALCONE] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_SALOTTO-BALCONE] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_INGRESSO-MURO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT-INGRESSO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_CORRIDOIO-INGRESSO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_CORRIDOIO-INGRESSO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_CORRIDOIO-LETTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_CORRIDOIO-LETTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PR_CUCINA-CAPPA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PR_CUCINA-CAPPA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_CUCINA-BALCONE] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW-CUCINA-BALCONE] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_CUCINA-SERRANDA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_DOCCIA-SPECCHIO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_DOCCIA-SOFFITTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PR-DOCCIA-SOFFITTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PR_DOCCIA-SOFFITTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:PL_LETTO-COMODINO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TR_LETTO-FINESTRA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_BAGNO-SPECCHIO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_BAGNO-SOFFITTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_BAGNO-MURO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:MT_BAGNO-MURO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TH_LETTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_MATTEO-SOFFITTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_IACOPO-SOFFITTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:SW_IACOPO-BALCONE] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TH_DOCCIA] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:TH_TERRAZZO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:WL_SALOTTO-TERMOSIFONE] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:WL-SALOTTO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:WL_CUCINA-LAVELLO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:WL_INGRESSO-TERMOSIFONE] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [warn] [zigbee2mqtt-in:WL_INGRESSO] You need to turn on the "retain" option for the device in Zigbee2MQTT to be able to read it before a state change.
15 Jul 17:06:23 - [info] [vsh-connection:roberto_brunialti@tiscali.it] MQTT: attempting connection: a1pv0eq8s016ut-ats.iot.eu-west-1.amazonaws.com:8883 (clientId: vsht-350c0237-04ec-4a1d-a8d0-5d405f77f486)
15 Jul 17:06:23 - [red] Uncaught Exception:
15 Jul 17:06:23 - [error] TypeError: Configuration is not a constructor
    at main._inputCallback (/home/roberto/.node-red/node_modules/node-red-contrib-custom-chatgpt/chatgpt.js:31:35)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:214:26
    at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:206:11)
    at Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:190:25)
    at Node.receive (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:499:10)
    at deliverMessageToDestination (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:803:40)
    at Immediate.<anonymous> (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:819:21)
    at process.processImmediate (node:internal/timers:478:21)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Consumed 3.367s CPU time.

What does your settings file /home/roberto/.node-red/settings.js say about context stores?

Did the MQTT warnings show before the power fail?

The crash is from the chatgpt node. I suggest you disable or remove that for the moment.

It is possible your SD card has been corrupted by the power fail. It is rare but not unknown. Assuming you have a good backup you might just be better to restore from that (using a new SD card).

This should be the settings.js sectionù

     /** Context Storage
      * The following property can be used to enable context storage. The configuration
      * provided here will enable file-based context that flushes to disk every 30 seconds.
      * Refer to the documentation for further options: https://nodered.org/docs/api/context/
      */
     //contextStorage: {
     //    default: {
     //        module:"localfilesystem"
     //    },
     //},

I always used "ram" or "file" as store. I do'nt know if and how them have to be declared in settings.
MQTT seems working correctly
How can I disable chatgpt node if I cannot access the editor?

Ehm... I have not a good sd backup unfortunately. I had to. :frowning:

There is no ram context store there.

That isn't what I asked, which was whether the warnings are new or not. You may not know.

Immediately backup the whole .node-red folder, apart from the node_modules folder. Then if you have to, at least you have backup of your flows.

Show us the startup log if you use
node-red --safe
to start node-red

I changed context default module to "memory".
and used the command node-red --safe
I have an "all flows" backup. Do this type of backup preserve the palette packages?

roberto@RCORE:~/.node-red $ node-red --safe
15 Jul 19:20:35 - [info]

Welcome to Node-RED
===================

15 Jul 19:20:35 - [info] Node-RED version: v4.0.0
15 Jul 19:20:35 - [info] Node.js  version: v20.14.0
15 Jul 19:20:35 - [info] Linux 6.6.31+rpt-rpi-2712 arm64 LE
15 Jul 19:20:36 - [info] Loading palette nodes
15 Jul 19:20:37 - [info] Settings file  : /home/roberto/.node-red/settings.js
15 Jul 19:20:37 - [info] Context store  : 'default' [module=memory]
15 Jul 19:20:37 - [info] User directory : /home/roberto/.node-red
15 Jul 19:20:37 - [info] Projects directory: /home/roberto/.node-red/projects
15 Jul 19:20:37 - [warn] No active project : using default flows file
15 Jul 19:20:37 - [info] Flows file     : /home/roberto/.node-red/flows.json
15 Jul 19:20:37 - [info] Server now running at http://127.0.0.1:1880/
15 Jul 19:20:37 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

15 Jul 19:20:37 - [info] *****************************************************************
15 Jul 19:20:37 - [info] Flows stopped in safe mode. Deploy to start.
15 Jul 19:20:37 - [info] *****************************************************************

After

node-red-stop
node-red --safe

node-red editor started with flows disabled.
I disabled the chatgpt node ans deployed the flows
The flows seems working.
I did not understand what happened after the power fault.

Can you get into the editor now? If not, open the developer console in the browser and then refresh the page and see if there are any errors.

I don't know what an all flows backup is. Provided you have backed up package.json then you can re install additional nodes by going into the .node-red folder and running
npm install

I can get into the editor now. In this way, I was able to disable the ChatGPT node.
An "all flows backup" is the export of all flows as a json file
I did not change my node-red folder, so I still have all my previous packages
I do not understand what happened , neverthless now it seems working

That will only allow you to restore your flows, not your installed nodes, settings, node credentials etc.
Do what I suggested, which is to backup the complete .node-red folder. Then if you need to restore that all you need to do is install node-red if not already installed, restore the .node-red folder from your backup, go into that folder in a command window, and run
npm install

I just pushed an update to the ChatGPT node that should fix this error, it seems there were some breaking changes when switching from v3 to v4 of the OpenAI SDK.

15 Jul 17:06:23 - [red] Uncaught Exception:
15 Jul 17:06:23 - [error] TypeError: Configuration is not a constructor
    at main._inputCallback (/home/roberto/.node-red/node_modules/node-red-contrib-custom-chatgpt/chatgpt.js:31:35)
    at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:214:26
    at Object.trigger (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/hooks.js:166:13)
    at Node._emitInput (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:206:11)
    at Node.emit (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:190:25)
    at Node.receive (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:499:10)
    at deliverMessageToDestination (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:803:40)
    at Immediate.<anonymous> (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:819:21)
    at process.processImmediate (node:internal/timers:478:21)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Consumed 3.367s CPU time.

Let me know if you have any further problems.

It does'nt crash anymore but I get the following error in nodered:

17/7/2024, 13:12:12node: CHATGpt
msg : string[55]
"Cannot read properties of undefined (reading 'choices')"

Thank you for letting me know, that issue should be corrected now as well. (Sorry I don't have any way to test out my changes right now so I'm going in blind)

It is working now.
Thank you

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