Tips to reduce Node-RED flow conflicts

JavaScript/TypeScript

It’s hard to avoid merge conflicts when using Node-RED in a big project. I have fought against merge conflicts many times. You may be using a tool provided by Node-RED but I thought it was not handy, so our team decided not to use it. Instead, I shared my ideas to my colleagues to reduce number of conflicts and it works better than before. I will share the ideas here.

Sponsored links

Add new tab

This is easy solution when you add new features. You can place nodes wherever you want and the nodes that you add will never overlap over another node that other developers place. Do this when you face merge conflicts.

  1. Abort the rebase
  2. Start your flow and export keep it open
  3. Stop the flow
  4. Rebase again
  5. Accepts all changes
  6. Start the flow again
  7. Open the flow in different tab
  8. Copy your flow and paste it

Be careful not to open the new flow in the same tab. Another way is to export your changes in advance and paste it in notepad for example, then use it. You will have more tabs during the development but you can move those flows into one tab after your team finishes the work to the flow.

Sponsored links

Put all changes into one commit

This is a powerful way to resolve merge conflicts. I always put only a flow file when I save it. I don’t add other files like flow test file. Therefore, it is much easier to put those all changes into one commit by rebase with fixup or squash. You can include other files but it removes your commit history.
I often save my change and commit. It means that my development steps are small and many commits are piled up on the git history. If its branch is rebased I have to resolve the conflicts many times. Especially when I make a change to the same node or move nodes. This is horrible. It’s easier to make a merge mistake and it takes a while if you have many commits. We can avoid the problem by putting all flow changes together into one commit. I highly recommend this way.

Create a different task to make the flow readable

We need to make our code readable. Readability matters. However, it should be done after your current work finishes. If we move nodes to make the flow clean number of lines of merge conflicts increases. We need to resolve them one by one. I don’t move nodes while our team works on the same flow file. Instead, create a task to clean up the flow. No merge conflict occurs if we clean up the flow file as long as no one works on it.

Check following posts as well if you don’t know how to write Node-RED flow test.

Comments

Copied title and URL