Node-red not responsive hangs on "Starting flows"

So , was developing a "compiler" for a fleet of node-red devices, but got in a problem.
Whenever i install all of the dependencies from a list, and then restart node-red it hangs on :

Jan 18 18:59:55 G100-sn775 Node-RED[926]: 18 Jan 18:59:55 - [info] Server now running at http://127.0.0.1:1880/
Jan 18 18:59:55 G100-sn775 Node-RED[926]: 18 Jan 18:59:55 - [info] Starting flows

WebUI is not loading and stopping it (either with node-red-stop or systemctl) takes ~3-4 minutes.

node-red --safe does bring up the WebUI, and after deployment everything work as expected.

was thinking that it was dependency related (.node-red/package.json)
but its actually flow related, and that flow haves several functions that use mqtt, modbus-tcp , modbus-serial.
Any ideas where should i start debugging, or what 'automatic' solution i can incorporate ,maybe declaring them in settings.js instead of the function ?

Do you mean you install your dependencies from a node?

Yes, for example :

[
    {
        "id": "5299ad1a052e1e5c",
        "type": "function",
        "z": "3b94652596fabb28",
        "g": "58f290653fc6823f",
        "name": "SavedData",
        "func": "\nvar session_url = `https://${env.get('configuration').url}/datacalc?config={\"token\":\"${env.get('configuration').token}\"}&hvac=${env.get('configuration').hvacId}`;\nvar config = {\n    method: 'get',\n    url: session_url,\n    headers: {\n\n        'Accept': 'application / json, text/ javascript, */*; q=0.01',\n        'Accept-Language': 'en-US,en;q=0.5',\n        'Accept-Encoding': 'gzip, deflate, br',\n        'X-Operation': 'getdata',\n        'X-Requested-With': 'XMLHttpRequest',\n        \"Connection\": \"keep=alive\",\n        \"Sec-Fetch-Dest\": \"empty\",\n        \"Sec-Fetch-Mode\": \"cors\",\n        \"Sec-Fetch-Site\": \"same-origin\"\n    }\n};\n\naxios(config)\n    .then(function (response) {\n        msg.response = response.data.Payload\n        node.send(msg);\n    })\n    .catch(function (error) {\n           console.log(error)\n    });\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
            {
                "var": "axios",
                "module": "axios"
            },
            {
                "var": "btoa",
                "module": "btoa"
            }
        ],
        "x": 230,
        "y": 120,
        "wires": [
            [
                "86e7f39741862c3e"
            ]
        ]
    }
]

I think you need to explain more on what you mean by "compiler"

The node you have posted, is just making a web request - not installing dependencies or anything - which seems a really strange thing to do in a Flow IMO

any reason your not using the HTTP Request Node?

also note: you have spaces in-between the accept header value application/ type. I don't know if that is valid

So, me and my team developed a flow compiler, we have a config file which we specify, and a flows library in a repository, and based on the config file we craft/compile in to .node-red/flows.json (managing flows and node id , implementing node configs, managing credentials...)
So sorry if you misunderstood me i have ~25 function nodes using external modules and i think that is what is causing the issue of not starting the flow. But have no idea how to debug it.

If you run top or a system monitor and then start node red is it hogging the processor? If so you have a loop of some sort in your flows or a function.

1 Like

As per @Colin's comment, check the process's.

Also - I strongly recommend moving away from var
var can have an effect on the global context - especially with something called config :grimacing:

use let or const

1 Like

It's hogging the proc, but i am not understanding how with --safe , and after deployment it works.
Can't complain its a rather complex flow for managing ventilation system's schedules by mqtt and http :1st_place_medal:

Taking a long time to stop is a classic symptom of processor hogging.

Possibly a subtle race condition so that a change in the startup sequence changes the symptom.

I had the same issue a while back.. and got it sorted as below

You have to identify the function or flow causing the "stopping/hanging" of startup.

  1. Start in SAFE mode (as you did)
  2. Disable latest flows , and keep the ones active you know are working properly
  3. Restart in normal mode
  4. repeat 1-3 until you have identified which flow is creating the issue
  5. Enable the flow which is causing the issue
  6. Disable the latest functions or nodes which you suspspect causing the issue
  7. Restart in normal mode .. if system fails to start ..tham start in SAFE mode and disable further functios
  8. repeat the process until you identified the funcion/node responsible for "Stopping/hanging" the start process

There are several reasons a function/node is not starting up properly during a fresh-start in comparision to a full-deploy afte a Safe-Mode start.

For me it helped to put a delay in front of the function/node when starting up (this will ensure all system resources are up and running)

As soon you have identified the function/node causing the issue you need to investigate specifically in regards to the function/node and may need to reach out to the function/node developer or here in the forum again.

I know this will not help you directly, but hopefully you can noarrow down the issue

have fun :wink:

Started redesigning the flow that was crashing. And will try to not start functions on start of the flows, which i think are causing all of these non sense, plus i need to add further functionalities to the flows, and starting from scratch makes the most sense.