Issue in deploying flow after modifying

Hi,
I have created simple custom nodes to send messages in Node RED. I'm facing issue when I modify the flow and deploy it. Changes wont get reflected first time. If I delete the changes and make same changes again, then it works. For example if I have a flow with nodes x, y , z with x -> y -> z and if I add a->y , this change doesn't get reflected first time. But if I delete node a and again add it second time, then it works. I'm not sure why this is happening.
I'm using Node-RED v3.0.2 and node.js v16.20.1. I'm building Node RED from source.

Any help on fixing this issue will be greatly appreciated.

If you try it on a normal install of node red do you see the same problem?

What do you mean by 'does not get reflected`? What exact symptom are you seeing?

Also what are these nodes a,x,y,z? Are they all custom nodes that you have created?

Thank you for the reply.

If you try it on a normal install of node red do you see the same problem?

I will try this normal install and check.

What do you mean by 'does not get reflected`? What exact symptom are you seeing?

When I make new connection a->y to the existing working flow x->y->z and deploy this new flow, the messages from node a are not sent to node y and the logs I have added in node a are not printed. But the flow x->y->z works fine. If I delete node a and reconnect it again to y second time, then message from node a is sent to node y and logs in node a are printed.

Also what are these nodes a,x,y,z? Are they all custom nodes that you have created?

yes, a, x, y, z are the custom nodes I have created which has simple functionality to send a message.

Is this related to your previous post in which you are trying to send a message when a new connection is made rather than under more normal circumstances? If so then I suggest continuing this on the original thread as it appears that the technique used to achieve that is not functioning as expected.

No, this is a different issue. This is not related to my previous post. I'm trying to send message under normal circumstances here.

In that case try it with the standard node-red and let us know the result.

sure, I will check and let you know.

I am facing the same issue with standard node-red too.

You will have to provide more detail as your current description is hard to understand.

Remember, we cannot see what you see and you havent linked us to a code repo or shown any code.

Can you provide a gif or series of pictures (with annotations) that clearly describe your issue?

I will share the github repo link for the code I have used soon

Under what circumstance does your node send messages? Is it when it receives a message? If it is then add logging into that code to see where it is failing.

@Steve-Mcl , @Colin Steps to reproduce the issue
I have added my test code in this github repository

Steps to reproduce the issue.

  1. Move to .node-red directory
    cd ~/.node-red

  2. Install custom-node
    npm install node-red-test/custom-node/

  3. Install send-node
    npm install node-red-test/send-node/

  4. Run node-red
    node-red

  5. Create the below flow

  6. Deploy the flow to see the below output of debug node
    {key : "dummy"}

  7. Update the flow as below by making new connections

  8. Deploy the updated flow to see below output
    Expected output -
    {key : "dummy"}
    {key : "dummy"}

    Produced output :
    {key : "dummy"}

  9. Delete the extra nodes you added Step 7 and deploy the flow. Add the extra nodes back again as in Step 7 and deploy. Now it produces output as expected.

Please let me know if you are able to reproduce the issue or if you have need any clarifications.
Note : The issue doesn't occur always but it occurs frequently

You have not responded to my previous post.

Under what circumstance does your node send messages? Is it when it receives a message? If it is then add logging into that code to see where it is failing.

I have created two nodes namely, send-node and custom-node. send-node sends message when it is deployed. custom-node forwards message when it receives input message

probably a race condition because you are attempting to send before the node is fully created (i.e. before the current block is finished) and, more importantly, before Node-RED has emitted its update events.

As a test, put the node.send call in a setImmediate, nextTick or setTimeout

e.g.

    msg._info = 'inside node creation, before it is fully registered'
    node.send(msg); 

    setTimeout(() => {
        msg._info = 'setTimeout'
        node.send(msg); 
    }, 1); // 1 ms
    setImmediate(() => {
        msg._info = 'setImmediate'
        node.send(msg);
    });
    process.nextTick(() => {
        msg._info = 'nextTick'
        node.send(msg);
    })

and check the msg using a debug (set to show full msg object)

1 Like

I will try this to see if it works @Steve-Mcl . Thank you

Sending message after node is fully created solves the issue. Thank you @Steve-Mcl for the solution. Thank you @Colin

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