How to use the new "complete" feature internally?

In my project, NR is embedded in another NodeJS app.
NR is used mainly so the user can slightly customize an otherwise fixed behavior (the main NodeJS app has a "default" behavior/process and the user can use NR to modify parts of this process).

The new "node.send/complete" is interesting to know when a node is done working on msg, or when a flow is complete for instance ...

Is it possible to use the NR runtime API to be notified "internally" (that is in the NodeJS app that embeds NR) when done() is called, in the same way the Complete node is notified but without actually using a Complete node ?

I built a custom status node that can target config nodes. To accomplish this, I grab that events fired by the runtime, in this case node-status. We'd have to look at the source if there is something like node-complete.

However, this is not documented API, so be careful.

RED.events.on('node-status', (ev) => {
    // do something
});

This is used in a custom node, but since you are embedding Node-RED in your own instance, you may have access to that event emitter, too.

Just a pointer in a direction one might be looking at...

1 Like

No, there is no internal API for this currently, but it is early days.

Some of the follow-on features it enables - flow timeouts, graceful shutdown, etc will all drive internal code changes and part of that is likely to be a programmatic way to tie into the events.

But it's too early to say what shape that will take.

2 Likes

thanks both of you for explanation/clarification ...

I'm looking forward to these features...

I have already snooped around in the designs repository a bit over the last weeks, very interesting proposals.

The graceful shutdown is something I am missing a bit, too. But implementing that feature properly can get very complicated, very fast in such an environment.

I am too keenly looking forward to the graceful shutdown feature. When is it (/are they) likely to be implemented?

Impossible to say. It sits in the backlog waiting to be prioritised, or for someone to contribute time and effort to help move it forward.

@knolleary You may have seen my post here. I am working with pm2, and very keen to perform graceful shutdowns.

If there is still time for NR to adopt it internally, I would like to explore the idea of managing it with pm2. What events/methods are available to the runtime currently to know if a flow is running or not? Perhaps, I am asking the wrong ques, so happy to be guided.