Random node ids in subflows

Hi guys,

The context: we're using Node-RED to interact with a conversational API, this means that at some point a custom node calls an endpoint and, when the conversation continues, the API triggers a particular event, at this point the flow should resume from the point it stopped.

The problem is with the code below

 function createNodeInSubflow(subflowInstanceId, def) {
   let node = clone(def);
   let nid = redUtil.generateId();

the id of a node inside a subflow is random, it changes at every restart, which makes impossible to use it as a reference for resuming the flow in the same point it was interrupted calling the API (in case Node-red restarts the original id is lost).

Is there a solution for this problem (having a deterministic reference of what node it's execute in the flow) which doesn't include

  • patching the core of Node-RED
  • keeping the "status" of the execution inside Node-RED (not a viable solution for us)

Thanks and sorry if this post is a little bit vague

Guido

You can use the _path property of the node. That is entirely deterministic between restarts.

Thanks, this is really helpful, one last question: is there an helper method to get the node instance given the path (or a way to send a msg to a node knowing the path).

Thanks again
Guido

There is not a helper function for that as it is not something regular nodes have any need to do.

1 Like

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