-
I tried the file nodes to write and read some JSON. While it works on regular NR it fails when running on the MCU: flow.json
On the MCU this results in:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 12 replies
-
Thanks for reporting this. It is an interesting problem. This is a continuation of a thread that began here. In summary, the problem is due to having multiple nodes that access the same file. The LittleFS file system used on microcontrollers does not synchronize across concurrent instantiations of a file. That means that bytes written by one node may not be immediately available to another node. In Node-RED on a computer, this is taken care of outside Node-RED. I'm unsure about the best way to provide the behavior on an MCU. It may be that having a single shared instance of the file is the most reliable approach, but it will be some work to investigate that fully and implement. |
Beta Was this translation helpful? Give feedback.
-
By "breaks hard", I understand you to mean "stops on the exception in the debugger." By default, the xsbug does stop on exceptions. That can be disabled if you like.
I'm not sure that the presence of catch-node is responsible for Node-RED not showing an exception. My impression is that Node-RED developers don't generally run connected to a JavaScript debugger, so they won't get a break. Am I misunderstanding? It is easy enough to eliminate this exception by checking if the file exists before instantiating it. I've committed that change. It isn't realistic to expect to eliminate every exception from the runtime though. It is a feature of the language that is commonly used. |
Beta Was this translation helpful? Give feedback.
-
I've taken another look at this. Here's the flow I used. flows.json[
{
"id": "abd95de12314b6a2",
"type": "tab",
"label": "file catch",
"disabled": false,
"info": "",
"env": [],
"_mcu": {
"mcu": false
}
},
{
"id": "0e8f652363aa2a4a",
"type": "inject",
"z": "abd95de12314b6a2",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "meaningless payload",
"payloadType": "str",
"_mcu": {
"mcu": false
},
"x": 240,
"y": 160,
"wires": [
[
"cfee59bed1c65735",
"b57a8a76e5c8a9d3"
]
]
},
{
"id": "b00d10e1309ca360",
"type": "catch",
"z": "abd95de12314b6a2",
"name": "catcher",
"scope": [
"cfee59bed1c65735"
],
"uncaught": false,
"_mcu": {
"mcu": false
},
"x": 290,
"y": 320,
"wires": [
[
"b57a8a76e5c8a9d3"
]
]
},
{
"id": "b57a8a76e5c8a9d3",
"type": "debug",
"z": "abd95de12314b6a2",
"name": "debug 85",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"_mcu": {
"mcu": false
},
"x": 510,
"y": 320,
"wires": []
},
{
"id": "cfee59bed1c65735",
"type": "file in",
"z": "abd95de12314b6a2",
"name": "filer",
"filename": "missing.txt",
"filenameType": "str",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"_mcu": {
"mcu": false
},
"x": 430,
"y": 160,
"wires": [
[]
]
}
] In the Node-RED Editor, here's what it shows. Using the Node-RED MCU Edition, here are the same messages in xsbug. They are functionally equivalent. Notes on the differences:
I think these are close enough that we can consider this issue closed for practical purposes. |
Beta Was this translation helpful? Give feedback.
I've taken another look at this. Here's the flow I used.
flows.json