Node-red: How to removes a flow that is blocking the service

Hello community,

we currently facing an issue with the Node-Red Microservice (V2.6.0).

In Node-Red a faulty flow was deployed which is blocking the service completely.

Log:

23 Apr 13:53:38 - [red] Uncaught Exception:
23 Apr 13:53:38 - [error] TypeError: Cannot read properties of undefined (reading 'forEach')
    at processValues (/usr/src/app/node_modules/node-red-contrib-modbustcp/modbustcp.js:342:18)
    at SetupLoop (/usr/src/app/node_modules/node-red-contrib-modbustcp/modbustcp.js:377:9)
    at ModbusTCPRead._inputCallback (/usr/src/app/node_modules/node-red-contrib-modbustcp/modbustcp.js:400:9)
    at /usr/src/app/node_modules/@node-red/runtime/lib/nodes/Node.js:214:26
    at Object.trigger (/usr/src/app/node_modules/@node-red/util/lib/hooks.js:166:13)
    at Node._emitInput (/usr/src/app/node_modules/@node-red/runtime/lib/nodes/Node.js:206:11)
    at Node.emit (/usr/src/app/node_modules/@node-red/runtime/lib/nodes/Node.js:190:25)
    at Node.receive (/usr/src/app/node_modules/@node-red/runtime/lib/nodes/Node.js:499:10)
    at deliverMessageToDestination (/usr/src/app/node_modules/@node-red/runtime/lib/flows/Flow.js:811:40)
    at Immediate.<anonymous> (/usr/src/app/node_modules/@node-red/runtime/lib/flows/Flow.js:827:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Does someone has an idea how we can remove this dedicated flow from the service.

We already tried:

  • to unsubscribe the Service and re-subscribe it → the service blocks after loading the Flows
  • to delete the Service, after deploying → the service is still loading the corrupted flow

Hi @dominik.huller,

A microservice restart is not really helping you as the nodes you’ve installed will be reinstalled after a restart.
The microservice stores it’s state in Cumulocity’s inventory API. So you could delete some of it’s state in order get the microservice to start again.

You could for example look for a managedObject with the c8y_nodered-settings attribute e.g. via this query: /inventory/managedObjects?query=$filter=has(c8y_nodered-settings). This managedObject contains the settings of node red including the installed nodes, that will also be reinstalled on a restart of the microservice.

Before you proceed, store a backup of this managedObject locally.

You can start by unsubscribe the node-red microservice.
You can now either delete the whole managedObject (you will loose all the settings) or you edit the JSON stored within the full attribute of the managedObject.

If you decided to edit the managedObject, you just need to remove the impacted nodes from the nodes attribute of JSON object. In your case it is probably: node-red-contrib-modbustcp.

After you’ve removed/updated the managed object, you can again subscribe the node-red service and the service should no longer run into this issue since the node is no longer available. You can then remove the problematic node from you flow and afterwards reinstall the nodes you’ve removed previously if you still want to use them.

Alternatively you can also search through the flows stored in the inventory, by looking for managedObjects with the c8y_nodered-flows attribute.

Regards,
Tristan

1 Like