Why is close event not fired on disabled node delete?

Hi Node-RED team, good afternoon, I have a question related to the lifecycle of nodes in the context of developing custom nodes with external services.

When you delete a node, the flow is as follows:

  1. The oneditdelete event is fired on the node configuration running in the editor (frontend).
  2. If you then deploy that flow, the 'close' event is triggered in the node backend, and you can be sure that this node is going to be deleted.

This first flow is okay for me.

In contrast, when you disable and then delete a node, the following occurs:

  1. The close event is triggered in the node backend after the deploy event.
  2. After that, if you delete the node, the oneditdelete event is fired on the node configuration running on the editor (frontend) but if you then perform a new deploy of the flow, you won't be notified of the removal again. I think that, since the removed flag indicates both disabling and removal, it should be fired twice anyway.

Therefore, it would be useful to have the close handler called when a disabled node is deleted.
What's your opinion on this?

Thanks

1 Like

I think this has merit.

Whilst I have not witnessed this myself (through lack of needing to make use of the flag)

If the backend is being passed the reason, it should see both Events.

A node doing magic due to it being disabled only, should also be updated later if removed.

A node might need to remove say some cached data when REALLY no longer needed.

Again - I haven’t witnessed it (I don’t use the flag) - but if it is a thing, then I agree.

calling close twice won't do anything different the second time around - so if you need to clear up you should do it correctly the first time. The oneditdelete event is indeed just for the edit(or) side to remove it from the palette and clean up the front end.