So I have reproduced this with two projects with one tab each.
- Start Node-Red from the command line
- create 'project A', insert this flow and deploy
[{"id":"cc0489ce.3b992","type":"tab","label":"Flow A ","disabled":false,"info":""},{"id":"a6585a7b.1c95b8","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"25c6c8ec.665608","type":"inject","z":"cc0489ce.3b992","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":150,"y":40,"wires":[["8b4bb50c.ada018"]]},{"id":"8b4bb50c.ada018","type":"change","z":"cc0489ce.3b992","name":"Set 'flow.movefile' to true (testing)","rules":[{"t":"set","p":"movefile","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":120,"wires":[["f784e40f.7728f"]]},{"id":"f784e40f.7728f","type":"debug","z":"cc0489ce.3b992","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":150,"y":200,"wires":[]}]
- create 'project B', insert this flow and deploy
[{"id":"7208c0c6.105408","type":"tab","label":"Project B","disabled":false,"info":""},{"id":"1ab4cfdc.a4ac5","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"true","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"8c60a36f.c85da8","type":"ui_group","z":"","name":"LED ","tab":"e7eda5d6.a835a8","order":1,"disp":true,"width":"8","collapse":false},{"id":"e7eda5d6.a835a8","type":"ui_tab","z":"","name":"LEDs","icon":"dashboard","order":6,"disabled":false,"hidden":false},{"id":"caed8c62.99b478","type":"function","z":"7208c0c6.105408","name":"Turn selected LED ON or OFF","func":"// var groupID = 6;\n\n// var nodeID = 90;\n\nvar groupID = flow.get(\"groupID\")||0;\nvar nodeID = flow.get(\"nodeID\")||0;\n\nvar logic_state = msg.payload.state;\n\nvar gpioPin = msg.payload.pin;\nmsg.payload=\"event,sendAction=\"+groupID+\",\"+nodeID+\",\"+logic_state+\",\"+gpioPin;\n\nvar date = new Date(); // Or the date you'd like converted.\nisoDate = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString();\nmsg.date = isoDate.slice(0,10);\nmsg.time = isoDate.slice(11,19);\n \nnode.status({fill:\"green\",shape:\"dot\",text:\"Last request to node\"+ nodeID + \" was made at: \" + msg.time + \" on \" + msg.date}); \n\nreturn msg;","outputs":1,"noerr":0,"x":230,"y":320,"wires":[[]]},{"id":"5892fb98.c071cc","type":"ui_button","z":"7208c0c6.105408","name":"RED led","group":"8c60a36f.c85da8","order":7,"width":"1","height":"1","passthru":false,"label":"","tooltip":"","color":"white","bgcolor":"{{msg.background}}","icon":"highlight","payload":"1","payloadType":"str","topic":"","x":160,"y":240,"wires":[["a9033ce.3d8d24"]]},{"id":"424d6907.a869c","type":"function","z":"7208c0c6.105408","name":"","func":"var red_status = flow.get(\"red_status\")||\"off\";\n\nif (red_status == \"off\")\n{\n msg.background=\"grey\";\n}\nelse if (red_status == \"on\")\n{\n msg.background=\"red\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":150,"y":180,"wires":[["5892fb98.c071cc"]]},{"id":"d1b66fb5.25f898","type":"inject","z":"7208c0c6.105408","name":"Initial conditions","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":"1","x":160,"y":60,"wires":[["8b782467.f57d68"]]},{"id":"a9033ce.3d8d24","type":"function","z":"7208c0c6.105408","name":"","func":"//var red_status = \"off\"; \n//red_status = flow.get(\"red_status\")||\"off\";\nvar red_status = flow.get(\"red_status\")||\"off\";\n\nif (red_status == \"off\")\n{\n red_status = \"on\"\n msg.background=\"red\";\n msg.payload = {\"pin\":15,\"state\":1}\n}\nelse if (red_status == \"on\")\n{\n red_status=\"off\"\n msg.background=\"grey\";\n msg.payload = {\"pin\":15,\"state\":0}\n}\nflow.set(\"red_status\",red_status);\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":240,"wires":[["5892fb98.c071cc","caed8c62.99b478"]]},{"id":"8b782467.f57d68","type":"change","z":"7208c0c6.105408","name":"Set inital conditions","rules":[{"t":"set","p":"red_status","pt":"flow","to":"off","tot":"str"},{"t":"set","p":"yellow_status","pt":"flow","to":"off","tot":"str"},{"t":"set","p":"green_status","pt":"flow","to":"off","tot":"str"},{"t":"set","p":"nodeID","pt":"flow","to":"25","tot":"num"},{"t":"set","p":"groupID","pt":"flow","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":170,"y":120,"wires":[["424d6907.a869c"]]}]
-
Switch back to project A
-
from the command line ctrl-c out of NR
-
open a os window so you can watch the .node-red directory contents. If there is a context folder, delete it. Sort the view by date show you can watch the context folders appear.
-
start NR again
-
in NR click the inject button for the first flow then quickly go to the projects option and switch to the other project, Press the inject button and swap back to the terminal and ctrl-c out of NR.
-
at this point you if you look at the contect folder, you should see two sub folders. If you open them both one should have a flow.json that is 9 bytes long. If you open it it will contain the word undefined
.
If you try to start NR it will crash with the above information.
If you delete the context folder that contains that 9 byte flow.json file, NR will start up fine.
My guess is that since the first project's context wasn't written out when swapped to the second project, something is hanging around and when NR is shut down, the contect fiiles are written, but the original one's data is gon and that is why it is undefined (of course I could very very wrong too )