Clean-up if no deployment is done?

What's best practice how to behave with backend-resources (e.g. clean-up?) if I created some as part of my config-nodes but no deployment was executed at the end? Any hook I could take advantage of?

No, there is no hook if the user decided to just close the editor without deploying any pending changes.

If you're nodes create resources outside of Node-RED, you need to have a way to tidy them up yourself.

OK, what about the opposite: where would you sanitize external resources when loading the editor (e.g. make sure only used resources are kept but clean-up unused)?

Where would you sanitize external resources when loading the editor

It isn't a usage pattern I've ever considered. Nor is it something you can rely on - what if someone deploys flows and doesn't open the editor again?

Likewise, if someone stops node-red, deletes the flows file and restarts with a blank workspace - hwo do you plan to tidy up the remote resources?

As I said previously, you do have the node id in the oneditcancel event. That's your best opportunity to tidy up the remote end if necessary - but you'll have to have some way to map the node id to the resource you need to tidy.

If you copy and paste a sample flow from the forum but decide not to deploy it, maybe because it uses nodes you don't have installed, it creates dashboard tabs and groups and configuration nodes.

It would be nice if there was a way to automatically delete those

If you have not deployed then CTRL Z will undo the paste.

what if someone deploys flows and doesn't open the editor again?

Agreed. My reasoning is that your case would be a one time thing then... what I would like to avoid is that a "bad behaving user" repeatedly sets up stuff but never deploys...

Likewise, if someone stops node-red, deletes the flows file and restarts with a blank workspace - hwo do you plan to tidy up the remote resources?

That's exactly the question. In this case I would like to figure out at start-up that no resources are actually still in use and therefore I would clean-up the resources in the backend.

As I said previously, you do have the node id in the oneditcancel event. That's your best opportunity to tidy up the remote end if necessary - but you'll have to have some way to map the node id to the resource you need to tidy.

I know and I already followed your advise: I now take the node-id and map all the resources to it. Unfortunately (I believe) this only helps if someone "cancels" a node (and therefore I'm allowed to delete the resource which just got created in the backend). However, if the node gets properly created but the flow never deployed that's of no help...

If you have not deployed then CTRL Z will undo the paste.

Sure, but I guess not many users would follow this best practice (as it's completely optional).

I was responding to @jbudd's post about the config nodes. Using Undo removes the config nodes that have been imported with a flow.

1 Like

What about a different approach: would it be possible to (re-)create the "undeployed" config-nodes on the backend when a user opens the editor later? With this approach it would be visible to users what resources actually exist (and a user would at least have the possibility to delete them).

If this is possible can anybody guide me where to do that best? I believe I would need to read out all the existing config-node instances first and the create the non-existing...

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