Custom node subscribed to flow restart event

Is it possible for my custom node to subscribe to the flow restart event? This would be to allow me to run some code when the flows restart.


Which flow? All flows on all tabs? just your node? the flow your custom node is on?

When the deploy affects the custom node it will re-initialise it. Put `console.log("xxx") thoughout your custom node .js file - you will see one or more in the console log entries when you re-deploy.

The scenario is this, I make a change in the editor and click the Deploy button. That appears to restart all flows. When a given flow restarts, I need to execute code within that flow.

I added a ridiculous number of console.log() statements, and it appears that it runs the node.on("close", function (done) { function, but the function stops in the middle (I'm guessing it takes too long and the framework just kills it). I think I can work with "close".

It depends what you are trying to do. Is it the stopping of the flows you care about, or the starting of them?

You cannot do lots of work in the close event - you certainly can't assume the flow you're wired to is all still running as the runtime is busy stopping everything.

Whenever the flows are restarted, your node will be recreated - so its constructor function will get called. If you want it to do something whenever a deploy happens, that is the place to do it.

Note that the Deploy button has a number of options in its drop down selection. If it is set to Modified Nodes, for example, only nodes that have been modified will be restarted, so your node will not see the event (unless it is one of the ones that has been modified of course).

1 Like

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