# How does the Complete node work?

**URL:** <https://discourse.nodered.org/t/how-does-the-complete-node-work/64733>\
**Category:** General\
**Created:** [5 July 2022 16:39 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733 "2022-07-05T16:39:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![phoddie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/phoddie/32/64232_2.png) [@phoddie](https://discourse.nodered.org/u/phoddie)\
**Post date:** [5 July 2022 16:39 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733/1 "2022-07-05T16:39:29Z")

</div>

I am looking to implement `Complete` node support for the [Node-RED MCU Edition](https://github.com/phoddie/node-red-mcu) exploration. I've been able to understand many of the built-in nodes well enough to re-implement them, at least in part, for MCU.

I don't really understand the `Complete` node. I'd like to, so I can try to implement it. The documentation explains:

> Trigger a flow when another node completes its handling of a message.

That seems similar to `catch` and `status` nodes. But, I'm not sure how a node indicates it is complete. The documentation notes...

> Not all nodes will trigger this event - it will depend on whether they have been implemented to support this feature

... but doesn't explain which nodes do trigger a complete. It mentions the "Email sending node" supports complete.

I guess have two questions:

1. Do any of the core built-in Node-RED nodes support Complete? That would make it straightforward for me to explore the behavior directly by building some test flows.
2. Other than digging into the full Node-RED sources (which is a big project!), what's the best way to learn how nodes implement support for Complete?

Thank you!

---

<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:** [5 July 2022 16:41 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733/2 "2022-07-05T16:41:54Z")

</div>

Generally best to give the full name for a node, a generic name like "complete" makes people have to search.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 July 2022 16:42 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733/3 "2022-07-05T16:42:30Z")

</div>

I believe the OP is referring to the built-in complete node.

---

<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:** [5 July 2022 16:43 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733/4 "2022-07-05T16:43:43Z")

</div>

🤣 🤣 I'd forgotten that one existed! Never actually needed to use it.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 July 2022 16:45 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733/5 "2022-07-05T16:45:09Z")

</div>

@phoddie if a node uses the `done` callback` then it supports the complete node.

See here: "JavaScript file : Node-RED" [JavaScript file : Node-RED](https://nodered.org/docs/creating-nodes/node-js#receiving-messages)

---

<div class="post-metadata">

**Author:** ![phoddie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/phoddie/32/64232_2.png) [@phoddie](https://discourse.nodered.org/u/phoddie)\
**Post date:** [5 July 2022 17:06 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733/6 "2022-07-05T17:06:45Z")

</div>

@Steve-Mcl, that helps, thank you, And leads to some follow-on questions.

The document you refer to is clear. The `done` callback passes to the event handler must be bound to the msg, so that when `done()` is called, Node-RED knows which message is done / complete. I can emulate that behavior.

The Writing Functions document in the "[Finishing with a message](https://nodered.org/docs/user-guide/writing-functions#finishing-with-a-message)" section shows calling `node.done()`. A function can have multiple messages pending from what I've seen (the `Delay` node may receive several messages and wait to pass them along), so it doesn't seem that Node-RED can know which message is done when `node.done()` is invoked which makes it impossible to trigger the Completion node with message that has the correct message id.

Perhaps it is a implicit requirement that nodes that have multiple messages in-flight use the `done` callback provided by the event callback. But, can a `Function` node use the event mechanism (the reference you provided appears to be for implementing nodes using Node.js)?

---

<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:** [3 September 2022 17:07 UTC](https://discourse.nodered.org/t/how-does-the-complete-node-work/64733/7 "2022-09-03T17:07:03Z")

</div>

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