This is a follow-up to my previous post with this same subject ("How does the Complete node work?"). The original has been closed because I took a little too long to follow-up.
The news is all good. I now have a working implementation of the Complete
node in Node-RED MCU Edition. That work led to a rewrite of the Catch
node. The behaviors of Complete
and Catch
match the full Node-RED as best as I can tell. They support done()
, node.done()
, and node.error()
in a compatible way with the full Node-RED.
The runtime overhead of done()
was reasonably high in the initial implementation because a done()
function closure was created for each message delivered to each node. I think this is similar to what full Node-RED does. The second implementation uses the nodered2mcu
preprocessor to determine which nodes need a closure for done()
. For nodes not referenced by a Complete
or Catch
node the done
function can be an empty function with no closure, which reduces the runtime overhead considerably for many flows. (Details of this are explained in the Implementation Notes section of the Node-RED MCU Edition read me
.)
FWIW – the way I finally understood how done()
works with Complete
and Catch
nodes was to read the source code of built-in nodes that use call done()
including sort
, delay
, and trigger
. It was helpful to think of Complete
and Catch
as outputs of the nodes included in their scope. A node's output has wires to indicate where to send messages, whereas the Complete
and Catch
nodes use their scope to indicate from where to receive messages.