setTimeout usage and 'Deploy' kills it

To start a function after a given time 'eTime' I use a function block setTimeout(function () {..}, eTime). If a 'Deploy' is made within the NR editor, the specified timeout time is canceled. Can this be prevented? If not, what alternative is there?

Are you deploying full?
You can just deploy modified nodes or flows

Good point! But I can't quite get my head around it.
Suppose the setTimeout function is on an editor page ... a 'flow'. If I change an element on this flow, the element gets a blue dot. Regardless of whether I select Deploy for Node or Flow, the blue dot remains, and the 'Deploy' button remains red. This means that the changes are not applied. And the setTimeout is still active.
But that can't be the solution!
Only the full Deploy takes the change of the element .. and destroys the setTimeout!

But basically I read from the answer, yes "Deploy" resets a setTimeout function. Right?
Ask asked before: any alternative for "setTimeout"? Maybe using context/flow/global variables?

A full deploy stops all nodes > deploys all nodes > restarts all nodes.
A modified node deploy stops modified nodes > deploys modified nodes > restarts modified nodes.

Sorry, can't see that ...
What could I have done wrong with the "partial deploy"?

For anyone else reading this...

Full Deploy: Restarts Node RED (in theory)
Modified Flows: Restarts A flow if anything in that flow has changed
Modified Nodes: Restarts only nodes that has been modified

@gNeandr Example: if you have Modified Flows set - and changed one node in that flow, and deploy - all nodes will get restarted in that flow

If you select Modified Nodes from this dropdown it changes the function of the Deploy button but it does not deploy anything. You still need to click Deploy.

The Deploy button changes to this to indicate "Changed nodes only" mode.

1 Like

OK, I didn't pay attention to the fact that the Deploy pulldown is "only" a selection menu.
The Deploy button is changing its function by the pulldown selection and only the use of the button parts makes the Deploy as selected.
Nice learning :crazy_face:

Any suggestion for the setTimeout NOT to alter ? :face_with_raised_eyebrow:

Thanks, I've just noticed.
Nice to see that help is here :smiley:

1 Like

So can you now deploy without resetting the timeout, as long as you didn't move or modify that node?

Will try to do so.
Just changed some nodes on the flow, but not the function node with the setTimeout.
atm a setTimeout is "active" for some more 20min, will trace if it's working as expected ... coming back later

Just to be grumpy here.... :older_man:

Consider using a trigger or delay Node (whatever works best), whilst using context to store anything that might be needed later, at the point of execution.

but granted, it might not be suited for your requirement, just keep it in mind.

OK, first, the function initiated with the setTimeout did what it should do after elapse. So basically all is fine because of the right deploy.

Thanks for the idea of trigger and delay, have to check for that.

1 Like