Hung during deploy

I was just making flow changes, and out of the blue when I pressed deploy, I got a server not responding message. I checked and the server is fine, but node-red isn't working anymore. When I try to stop it I get

Stopping Node-RED graphical event wiring tool...
nodered.service: State 'stop-sigterm' timed out. Killing.
nodered.service: Killing process 1542 (node-red) with signal SIGKILL.
nodered.service: Main process exited, code=killed, status=9/KILL
Stopped Node-RED graphical event wiring tool.
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'timeout'.

It ends up stopped, and when I start it, everything looks like it's starting up, but I can't connect to it from my browser. What's my next step to bring it back to life?

Run, in a terminal

node-red-stop
node-red-start

and see what you get. Post it here if necessary, from the Welcome to node-red message. If you haven't got those commands then

sudo journalctl -f -n 25 -u nodered -o cat

and if necessary restart node-red

Welcome to Node-RED

18 Feb 20:03:13 - [info] Node-RED version: v0.19.5
18 Feb 20:03:13 - [info] Node.js version: v10.15.1
18 Feb 20:03:13 - [info] Linux 4.14.79-v7+ arm LE
18 Feb 20:03:14 - [info] Loading palette nodes
18 Feb 20:03:19 - [info] Dashboard version 2.13.2 started at /xxx/ui
18 Feb 20:03:19 - [info] Settings file : /home/user/.node-red/settings.js
18 Feb 20:03:19 - [info] Context store : 'default' [module=localfilesystem]
18 Feb 20:03:19 - [info] Context store : 'memory' [module=memory]
18 Feb 20:03:20 - [info] User directory : /home/user/.node-red
18 Feb 20:03:20 - [info] Server now running at https://127.0.0.1:nnn/xxx/
18 Feb 20:03:20 - [info] Active project : Automation
18 Feb 20:03:20 - [info] Flows file : /home/user/.node-red/projects/Automation/flows_home-assistant.json
18 Feb 20:03:20 - [info] Starting flows
18 Feb 20:03:20 - [info] Started flows
18 Feb 20:03:21 - [info] [server:Home Assistant] WebSocket Connected to https://xxx.duckdns.org:nnn

What did you change before the problem occured?

I was just playing around with a flow I' ve been working on for days. I'm working on a dashboard that sends out gets and posts to my Bose stereo. Nothing memorable right before the deploy that hung. I did apply an update to the websockets node that was installed. I have a connection to my Home Assistant instance that uses websockets. I haven't done anything with that part of my flow in a while. I restarted after that update and was working for a while before the problem. I have my project in git, and did a commit about an hour before this happened.

does it continue to hang after you bring it backup?

I notice you are not running on port 1880...why?

What websocket node are you using?

As far as I can tell, it doesn't come up. I can't connect to it fro my browser anymore. I just switched ports for a bit of added security. I'm not sure what websockets I have, and I don't know how to check with the system down.

I started in debug mode and found out what the websocket node was:

node-red-contrib-home-assistant-websocket

So, I reloaded the my project flow from github and I'm back in action. I guess the flow file got corrupted somehow?

I recreated the additional changes since the last commit and it hung again. I was changing some js in a function. It looks like this is repeatable.

Have you got a loop in your js? You could post it for us to have a look at.

1 Like

We have a winner!

Not only did I have a loop, but I had an infinite loop! And the icing on the cake is the fact that when my flow starts it has an injection node that calls that function immediately. Without that injection node the deploy would have returned successful, and NR would only have hung up when I manually called the function.

Some good lessons learned here for me.

  1. node-red-stop will eventually stop NR, even when an infinite loop is running. It just takes a few minutes.
  2. Once NR is stopped I can easily recover from the last flow saved in github.
  3. Be very careful when using an injection node that is set to automatically inject after a deploy.
  4. No more infinite loops in functions!

Thanks for your help!