You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After power failure, there is a certain probability that the context storage file data will be emptied with a length of 0. What causes this problem? Is the operation of clearing data occurred during power failure or during NR startup?
that sounds very strange. The context LocalFileSystem module takes care not to corrupt its files. It writes updates to a temporary file and then does a rename to move the temporary file over the proper file as a final step. That should ensure we never leave the proper file in a bad state.
The fact you are using Docker may be of interest.... what docker image are you using and how is it configure to store user data?
I have seen this many times running on Windows on an NTFS disk. Is it possible that the write to the temp file is not committed to disk, but the delete/rename "overtake" it in the queue somehow? The file system operations behind delete and rename are more complex.
The annoying thing is that it stops NR from starting. As it can affect a random file, you then have to scan through all the context files looking for the one with zero length, delete it, and restart NR.
Hi, we discover the same issue running NR on Windows. We set to flush the context variables to the local file system. In case the PC is shut down immediately, e.g. due to power loss, at next startup, NR terminates with "Error loading context store".
Our workaround is to create a backup of the context directory (when needed and when the PC is running properly) and restore this backup on each startup of NR, to ensure NR starts. However, this limits the possible use of storing to disc considerably.
We would be looking forward to a solution which avoids creating these invalid context files. (We haven't found what could be exactly the problem in the source code of NR)
Another approach would be to programmatically create a backup of the context folder (like for the flows) and restore this backup if starting NR fails for the abovementioned error. Or, if this doesn't help, start NR with cleared context directory. Not starting at all is a critical issue thinking of automated operation.
Best regards
Stefan
Node-RED version: v1.0.4
Node.js version: v10.16.3
npm version:
Platform/OS: Win10 x64
Browser:
running in Docker: no
Same issue here on Windows. Power loss cause the global context file to be cleared.
@marcusekeenan this issue is almost 2 years old & many things have changed since node-red v1.0.4
You will need to detail your node/node-red version, how you have set up persistent storage in your settings file and any other relevant info (like running in docker, or as a home assistant pluggin, running as a service etc etc etc)
Closing as part of a tidy-up of the issue tracker — this has been inactive for a long time and much has changed in Node-RED since. If it's still relevant on a current version, please open a fresh issue with up-to-date details and we'll take a look. Thanks for raising it.
Activity
knolleary commentedon Oct 14, 2020
Hi @tanjie9012 ,
that sounds very strange. The context LocalFileSystem module takes care not to corrupt its files. It writes updates to a temporary file and then does a rename to move the temporary file over the proper file as a final step. That should ensure we never leave the proper file in a bad state.
The fact you are using Docker may be of interest.... what docker image are you using and how is it configure to store user data?
csmale commentedon Nov 18, 2020
I have seen this many times running on Windows on an NTFS disk. Is it possible that the write to the temp file is not committed to disk, but the delete/rename "overtake" it in the queue somehow? The file system operations behind delete and rename are more complex.
The annoying thing is that it stops NR from starting. As it can affect a random file, you then have to scan through all the context files looking for the one with zero length, delete it, and restart NR.
stefankapp commentedon Nov 27, 2020
Hi, we discover the same issue running NR on Windows. We set to flush the context variables to the local file system. In case the PC is shut down immediately, e.g. due to power loss, at next startup, NR terminates with "Error loading context store".
Our workaround is to create a backup of the context directory (when needed and when the PC is running properly) and restore this backup on each startup of NR, to ensure NR starts. However, this limits the possible use of storing to disc considerably.
We would be looking forward to a solution which avoids creating these invalid context files. (We haven't found what could be exactly the problem in the source code of NR)
Another approach would be to programmatically create a backup of the context folder (like for the flows) and restore this backup if starting NR fails for the abovementioned error. Or, if this doesn't help, start NR with cleared context directory. Not starting at all is a critical issue thinking of automated operation.
Best regards
Stefan
Node-RED version: v1.0.4
Node.js version: v10.16.3
npm version:
Platform/OS: Win10 x64
Browser:
running in Docker: no
marcusekeenan commentedon Sep 2, 2022
Same issue here on Windows. Power loss cause the global context file to be cleared.
Steve-Mcl commentedon Sep 4, 2022
@marcusekeenan this issue is almost 2 years old & many things have changed since node-red v1.0.4
You will need to detail your node/node-red version, how you have set up persistent storage in your settings file and any other relevant info (like running in docker, or as a home assistant pluggin, running as a service etc etc etc)
DmitrySidorow commentedon Jun 26, 2025
today I came across the fact that the file was empty after an unexpected power outage. I will store it in sqlite
knolleary commentedon Jun 10, 2026
Closing as part of a tidy-up of the issue tracker — this has been inactive for a long time and much has changed in Node-RED since. If it's still relevant on a current version, please open a fresh issue with up-to-date details and we'll take a look. Thanks for raising it.