# Corrupt context file causes Node-RED server to fail to start

**URL:** https://discourse.nodered.org/t/corrupt-context-file-causes-node-red-server-to-fail-to-start/92272
**Category:** Core Development
**Created:** [9 October 2024 16:57 UTC](https://discourse.nodered.org/t/corrupt-context-file-causes-node-red-server-to-fail-to-start/92272 "2024-10-09T16:57:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [9 October 2024 16:57 UTC](https://discourse.nodered.org/t/corrupt-context-file-causes-node-red-server-to-fail-to-start/92272/1 "2024-10-09T16:57:09Z")

</div>

It doesn't quite feel right that a corrupted context file should prevent Node-RED from starting - is that expected behaviour?

If so, could that error be better trapped with an error message and the server allowed to continue?

```auto
0|Node-RED | 9 Oct 13:33:06 - [error] Failed to start server:
0|Node-RED | 9 Oct 13:33:06 - [error] Error: Error loading context store: Error: Invalid JSON in context file 'D:\src\nr\data\context\ba86b64531fa3971\cb93e1c6dee6854a.json'
0|Node-RED | at D:\src\nr\node_modules\@node-red\runtime\lib\nodes\context\index.js:180:15

```

---

<div class="post-metadata">

### Author: ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)
#### Post date: [9 October 2024 17:45 UTC](https://discourse.nodered.org/t/corrupt-context-file-causes-node-red-server-to-fail-to-start/92272/2 "2024-10-09T17:45:09Z")

</div>

I think, I've seen GH issues (or Forum) about this before.

Would a setting to automatically delete the corrupted file and then regenerate it be a better option?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [9 October 2024 19:57 UTC](https://discourse.nodered.org/t/corrupt-context-file-causes-node-red-server-to-fail-to-start/92272/3 "2024-10-09T19:57:00Z")

</div>

> [@GogoVega](#):
>
> Would a setting to automatically delete the corrupted file and then regenerate it be a better option?

I would prefer not to be honest. I'm not sure what corrupted the file though I did have a Blue Screen crash today which might have been it - I don't believe that was related to Node-RED BTW.

I renamed the file because I wanted to check out what it contained but needed Node-RED to restart. That would be my preferred outcome I think because when it did start up, the file - with all valid data was re-created.

I've not had time to look to see if that was because I have a startup inject that creates it, it was test data after all so that may well be the case.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [8 December 2024 19:57 UTC](https://discourse.nodered.org/t/corrupt-context-file-causes-node-red-server-to-fail-to-start/92272/4 "2024-12-08T19:57:17Z")

</div>

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