Enable node actions within subflows

When I try to use node actions within subflows, I get the Warning: node actions disabled within subflow error.

Our project is modularized into subflows to make things more readable and maintainable. I was also hoping that this would allow us to use the node-red-contrib-flow-asserter module to create "unit tests" for each subflow that we can run while developing within the subflows. However, this module requires being able to take actions within the subflow in order to run the tests. I could theoretically create a separate flow page that tests subflows by doing basic blackbox input to output testing of the subflows, but I would like to be more granular than that. There is some logic that happens in the subflows that would not be able to be tested that way.

Other issues this creates:

  • Cannot use inject nodes in subflows to test them out or run them independently of whole flow
  • Cannot turn on and off debug nodes - have to add and delete them instead

The subflow functionality seems really powerful, but it feels like the inability to take actions from within subflows really holds it back.

:question:What is the reason behind this decision?
:question:Is this something that can be added to the future roadmap?

Current workarounds that I can think of:

  • Create separate flows and use http in/out messages between the flows to try and create an architecture that is kind of like implementing subflows
  • Try out the node-red-node-test-helper testing route, and manage all tests outside of node-red editor
  • Pull everything out of the subflows and put them into groups on one really big flow page

Hi @zachsitka

When you are editing the subflow you are editing the template for the subflow - not a concrete instance of it. You could have 20 instances of the subflow in your flows.

If you were to click on an Inject node's button inside the subflow template, we don't know which of those 20 instances should receive that action. This is why actions are disabled.

I'm sure some approach could be found where you can select which subflow instance actions should apply to - but we don't have any concrete proposals for the UX on that.

On the wider topic of flow testing, there is working going on to create a flow test framework - GitHub - node-red/node-red-flow-tester: A Flow Testing plugin for Node-RED - still very early and nothing functional to try out yet. But the goal is to allow flow developers to define test cases in the editor, and be able to run them either directly from the editor, or using an automated test runner as part of a CI/CD pipeline.

1 Like

A flow test framework would be a total game changer for us! I'm glad someone is already on it.

One "trick" I've used to develop and debug subflows is to simply copy all the nodes (except the input and outputs) and then paste them into a new flow. Then add inject, debug or other nodes as needed to test any changes I make to the flow, which can be copied back into the subflow once complete.

You do lose a few things like instance-specific environment variables, but in general it gives a reasonable test method.

1 Like

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