Complete

What is the Complete Node?

The Complete Node in Node-RED is used to trigger a flow after a specified node completes its execution or a certain task. This is achieved by informing the Node-RED runtime about the completion of a task performed by the node itself.

In custom nodes, this support is typically implemented by calling the done() callback function after the execution of the task. This signals to the runtime that the task has been completed and triggers the Complete Node.

Note: While this node is supported by all nodes, only nodes that have implemented support by informing the runtime about the completion of a certain task can utilize it.

This node must be configured to handle events for selected nodes; it does not provide an option to enable event handling from all nodes automatically.

For notifying task completion in the middle of a function, you can use node.call in a function node.

Use Cases

  • Asynchronous Task Completion:

Suppose you have a flow where one node performs an asynchronous task, such as fetching data from an API. You can use the Complete Node to trigger the next set of actions in the flow only after the data has been successfully fetched.

  • Long-running Process Completion:

For processes that take a significant amount of time to complete, such as batch jobs, data transformations, or machine learning tasks, the Complete Node can be used to mark the end of these processes and trigger follow-up actions or notifications.

  • Batch Processing:

For batch processing tasks, the Complete Node can be used to signal the completion of a batch process. This could be useful in data processing workflows where data is processed in batches, and you need to know when each batch is finished before starting the next one.

  • Output-less Node:

In Node-RED, certain nodes like WebSocket-out and MQTT-out do not have outputs to connect with. The Complete node in Node-RED can be helpful when you need to know when a process is done by those nodes.

Example

  1. In the example flow below, we have a WebSocket server, the Inject node sends data to the WebSocket server, and upon successful transmission to the WebSocket server, a Complete node handles the event.

In the example flow below, we have an inject node sending an HTTP GET request to a mock API. After successful completion of the request, the complete node will handle the event.

Output Message:

When a task is completed by a specified node in the Complete Node, it emits the same message object emitted by that specified node.

Node Documentation

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

Details

If a node tells the runtime when it has finished handling a message, this node can be used to trigger a second flow.

For example, this can be used alongside a node with no output port, such as the Email sending node, to continue the flow.

This node must be configured to handle the event for selected nodes in the flow. Unlike the Catch node, it does not provide a 'handle all' mode automatically applies to all nodes in the flow.

Not all nodes will trigger this event - it will depend on whether they have been implemented to support this feature as introduced in Node-RED 1.0.