Weird: use of a button causes "Connection lost"

This is weird. I tried to add a button to an existing flow, to trigger part of the processing.
Button stays unchanged from the template. When I deploy and the trigger it, it causes a "Connection lost".
I tried several things, but finally decided to place a "bare" button on the dash, without any change and without any connections to other nodes. It still disconnects..... what am I doing wrong?

[{"id":"635f41f952f410cf","type":"ui_button","z":"e6084606.af1308","name":"","group":"feb1f4e4e26c1cb4","order":5,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":170,"y":240,"wires":[[]]},{"id":"feb1f4e4e26c1cb4","type":"ui_group","name":"selectie data","tab":"ca02b8f4ca43775c","order":2,"disp":true,"width":"15","collapse":false,"className":""},{"id":"ca02b8f4ca43775c","type":"ui_tab","name":"Energie jaarverbruik","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

The flow you provided is a single button and causes me no problem.

  1. export your current flow so you have a backup.
  2. move the button node to a new tab
  3. on all the other tabs, double click on the tab and at the bottom of the panel, click the 'Enable' button to disable the tab.
  4. once you have disabled all the tabs but the one with the button, deploy the low and go to the dashboard and click the button and see if it works.

If it works, enable a tab at a time and deploy and test again till you cause the problem. Then you will have narrowed down teh problem area.

It would also be good it you provided the NR and node.js versions and what platform and OS you are running nod-red on.

Have you checked the log in your browser or the error log of your Node-RED server?
Connection lost very often is caused by a termination of the server - due to an uncaught exception somewhere in a node.

Ah, interesting approach.
I did as you asked, new tab, with just a bare button, on a new group in the dashboard.
Then disabled all other tabs, and deployed.
Tested: same result. Pressing the button brings NR to it's knees....

My Node Red is at 2.4.1.
How can I find the node.js version?

Found something, but donot understand:

19 Jul 21:15:51 - [red] Uncaught Exception:
19 Jul 21:15:51 - [error] TypeError: isValidUTF8 is not a function
    at module.exports.isValidUTF8 (/home/pi/.node-red/node_modules/ws/lib/validation.js:120:53)
    at Receiver.dataMessage (/home/pi/.node-red/node_modules/ws/lib/receiver.js:517:43)
    at Receiver.getData (/home/pi/.node-red/node_modules/ws/lib/receiver.js:446:17)
    at Receiver.startLoop (/home/pi/.node-red/node_modules/ws/lib/receiver.js:148:22)
    at Receiver._write (/home/pi/.node-red/node_modules/ws/lib/receiver.js:83:10)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Receiver.Writable.write (_stream_writable.js:318:11)
    at Socket.socketOnData (/home/pi/.node-red/node_modules/ws/lib/websocket.js:1272:35)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
nodered.service: Main process exited, code=exited, status=1/FAILURE

There is no node-red V2.4.1

This is strange, indeed: Looks like there's an issue with(in) the ws (websocket) package.
What makes it even more strange: This package is used by NR internally for the communication between the NR client (in your browser) and the NR server. If it's not creating an exception there - why is it throwing with that button widget?

All version data is logged to the servers console at the start of Node-RED.

You haven’t said what device you are running NR on. If it is a Pi (or most other devices) you can open a terminal and start NR and then you will see the startup log. In the startup log it will tell you what version of node-red and node.js you are running.

I’d also suggest you start up node-red with a new flow name:

Node-red buttontest 

This will be an empty flow and you could add a button and test if it causes the issue. If it does we learn that the it’s not your original flow and if it doesn’t we learn it has to do with the original flow (in that case I’d ask you to post the whole original flow in a response if it is not confidential)

20 Jul 09:32:01 - [info] Node-RED version: v2.1.4
20 Jul 09:32:01 - [info] Node.js  version: v12.22.12
20 Jul 09:32:01 - [info] Linux 5.10.103-v7l+ arm LE
20 Jul 09:32:02 - [info] Loading palette nodes
BAIL ON node-red-contrib-file-function/file-function
20 Jul 09:32:05 - [info] Dashboard up and running
20 Jul 09:32:06 - [info] Dashboard version 3.5.0 started at /ui
20 Jul 09:32:06 - [warn] rpi-gpio : Raspberry Pi specific node set inactive

Thanks for providing a bit of the startup log so now we know you are running Node-Red v 2.1.4 and node.js v12.22.12 but you still haven't answered the question what device and OS are you using. And I have a couple more questions:

  1. what device and OS are you running NR on?
  2. are you using Home Assistant or running I a Docker container?
  3. did you try with a new flow and what was the result?
  4. If you tried a new flow with just a button node and it did not fail, are you going to provide your original flow.

If you what help please answer all the questions.

  1. running a Raspberry Pi 4, standard R-Pi OS
  2. using Domoticz, no docker
  3. yes. When the button failed in the original flow, I created a completely new flow with only the bare button
  4. the bare button did fail

Please stop NR and then restart it. Then click on the button. Then copy the full log (from when you enter node-red to when the error occurs and paste the results into a reply.

My suspicion it that this is Domoticz related.

It's not Domoticz related. I stopped Domoticz, then restarted NR. Same error.

Did as you asked:

node-red
20 Jul 14:28:45 - [info]

Welcome to Node-RED
===================

20 Jul 14:28:45 - [info] Node-RED version: v2.1.4
20 Jul 14:28:45 - [info] Node.js  version: v12.22.12
20 Jul 14:28:45 - [info] Linux 5.10.103-v7l+ arm LE
20 Jul 14:28:45 - [info] Loading palette nodes
BAIL ON node-red-contrib-file-function/file-function
20 Jul 14:28:48 - [info] Dashboard up and running
20 Jul 14:28:49 - [info] Dashboard version 3.5.0 started at /ui
20 Jul 14:28:49 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
20 Jul 14:28:50 - [warn] ------------------------------------------------------
20 Jul 14:28:50 - [warn] [node-red-node-rbe/rbe] 'rbe' already registered by module node-red
20 Jul 14:28:50 - [warn] ------------------------------------------------------
20 Jul 14:28:50 - [info] Settings file  : /home/pi/.node-red/settings.js
20 Jul 14:28:50 - [info] Context store  : 'default' [module=memory]
20 Jul 14:28:50 - [info] User directory : /home/pi/.node-red
20 Jul 14:28:50 - [warn] Projects disabled : editorTheme.projects.enabled=false
20 Jul 14:28:50 - [warn] Flows file name not set. Generating name using hostname.
20 Jul 14:28:50 - [info] Flows file     : /home/pi/.node-red/flows_Utrecht.json
20 Jul 14:28:50 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

20 Jul 14:28:50 - [info] Server now running at http://127.0.0.1:1880/
20 Jul 14:28:50 - [info] Starting flows
20 Jul 14:28:50 - [info] Started flows
20 Jul 14:28:50 - [info] [aedes broker:e620025b8f212d23] Binding aedes mqtt server on port: 1883
20 Jul 14:28:50 - [info] [mqtt-broker:698d3ae2.89ac94] Connected to broker: mqtt://localhost:1883
20 Jul 14:28:50 - [info] [mqtt-broker:c8b01a2a.39d8e8] Connected to broker: mqtt://localhost:1883
20 Jul 14:28:50 - [info] [mqtt-broker:Winterswijk] Connected to broker: mqtt://www.winterswijk28.duckdns.org:1883
20 Jul 14:28:56 - [info] nora: connected, uid: zFYSOzW4NnM2L8qCM0dM25i14Vx2
20 Jul 14:28:57 - [info] nora: synced 5 device(s), group: <default>
20 Jul 14:29:04 - [red] Uncaught Exception:
20 Jul 14:29:04 - [error] TypeError: isValidUTF8 is not a function
    at module.exports.isValidUTF8 (/home/pi/.node-red/node_modules/ws/lib/validation.js:120:53)
    at Receiver.dataMessage (/home/pi/.node-red/node_modules/ws/lib/receiver.js:517:43)
    at Receiver.getData (/home/pi/.node-red/node_modules/ws/lib/receiver.js:446:17)
    at Receiver.startLoop (/home/pi/.node-red/node_modules/ws/lib/receiver.js:148:22)
    at Receiver._write (/home/pi/.node-red/node_modules/ws/lib/receiver.js:83:10)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Receiver.Writable.write (_stream_writable.js:318:11)
    at Socket.socketOnData (/home/pi/.node-red/node_modules/ws/lib/websocket.js:1272:35)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

Just a quick observation... that is a very old version of Node-RED you are using.
The latest version is v3.0.2
If you can, it might be worth upgrading to a more recent version.

Can you copy/paste the contents of .node-red/package.json please. That may be helpful.

Since you are doing this with the flow with just the button node, could you remove node-red-contrib-file-function which is over seven years old and has a couple issues (on GitHub) open that the author has not replied to (last issue opened in 2017).

That would eliminate that as an issue and should remove the:

BAIL ON node-red-contrib-file-function/file-function

in the startup log.

rs/master/deb/update-nodejs-and-nodered){
  "name": "node-red-project",
  "description": "initially created for you by Node-RED 3.0.2",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "node-red-contrib-aedes": "~0.11.1",
    "node-red-contrib-buffer-parser": "^3.2.2",
    "node-red-contrib-play-audio": "^2.5.0",
    "node-red-dashboard": "~3.5.0",
    "node-red-node-pi-gpio": "^2.0.6",
    "node-red-node-ping": "^0.3.3",
    "node-red-node-random": "^0.4.1",
    "node-red-node-serialport": "^1.0.4",
    "node-red-node-smooth": "^0.1.2"
  }
}

OK, I am now sure it has to do with the installation.
I took a fresh Pi4, installed Raspberry OS, Domoticz, and Node Red.
Tried a button, and sure enough: no problem.

I am now thinking about running the Node Red install on my prod Pi, to give it a chance to correct any wrong stuff. Any thoughts on this?

Personally I would use this new Pi and add in two of the nodes in the dependencies list and try the button. If it works, add another two in. When it finally fails (if it does) then I'd remove one of the nodes you added and see it it fails. That should tell you which node is causing the issue.

But before you do that, what version of Node-RED are you running on this Pi? It could be an issue with the older version of NR you are running.

[EDIT] Ahh I just noticed you installed NR v3.0.2 so that could have cleaned up the problem.