Error on stop/restart

#1

I’m getting the following error when stopping or restarting Node-RED:

15 May 07:10:00 - [red] Uncaught Exception:
15 May 07:10:00 - Error: write EPIPE
    at _errnoException (util.js:1022:11)
    at WriteWrap.afterWrite [as oncomplete] (net.js:867:14)
nodered.service: Main process exited, code=exited, status=1/FAILURE

I don’t know which node is causing the error or where to begin to figure it out. I removed 2 of the custom nodes I was working on from the flows but the error is still present.

0 Likes

#2

Bump for help and adding a few characters

0 Likes

#3

Best place to start is usually to include the node-red console log output from when the server is started. That shows the versions of nodejs/npm/node-red/dashboard, plus the paths to your flow/static files…

Sounds to me like you have some incompatibility in software versions – so please include a description of the hardware and OS you are using.

0 Likes

#4

It’s a Raspberry Pi running Stretch Lite.

Everything is reasonably up to date, but here is the output from the service starting:

22 May 09:17:18 - [info] Node-RED version: v0.18.4
22 May 09:17:18 - [info] Node.js  version: v8.9.4
22 May 09:17:18 - [info] Linux 4.9.59-v7+ arm LE
22 May 09:17:20 - [info] Loading palette nodes
22 May 09:17:24 - [info] Settings file  : /home/pi/.node-red/settings.js
22 May 09:17:24 - [info] HTTP Static    : /home/pi/node-red-static
22 May 09:17:24 - [info] User directory : /home/pi/.node-red
22 May 09:17:24 - [info] Server now running at http://127.0.0.1:1880/admin/
22 May 09:17:24 - [info] Active project : timeclock
22 May 09:17:24 - [info] Flows file     : /home/pi/.node-red/projects/timeclock/flows_raspberrypi.json
22 May 09:17:25 - [info] Starting flows
22 May 09:17:28 - [info] Started flows
0 Likes

#5

Yep, that all looks good. So what command(s) are you using to start/stop the service? And if you stop it now that it’s running, do you always get the errors?

It sounds like a problem with the timing of the onClose function and the underlying network library. If this is a custom node, you may need a try/catch block around your cleanup code. I’m not sure if removing the nodes from your flows is enough to stop the errors anyway – you may have to actually npm remove them and restart node-red.

0 Likes

#6

I have Node-RED installed as a service so I’m just using sudo service nodered stop/restart. The error always appears. I did not think about removing the node with npm, I assumed that if it was not in use it would not be started. I’ll try un-linking the two nodes I made and see if that makes a difference. Once I can figure out what node is even causing the issue I should be able to fix it from there.

0 Likes

#7

I updated everything and removed the linked nodes I was working on, but the error is still there (although slightly different now)

22 May 10:34:31 - [red] Uncaught Exception:
22 May 10:34:31 - Error: write EPIPE
    at _errnoException (util.js:992:11)
nodered.service: Main process exited, code=exited, status=1/FAILURE

After that I got rid of all the nodes I had installed through the palette other than the SQLite node and I am still seeing the error. After updating the SQLite node I now see this error:

22 May 11:06:33 - [red] Uncaught Exception:
22 May 11:06:33 - Error: write EPIPE
nodered.service: Main process exited, code=exited, status=1/FAILURE

The error message keeps getting smaller and smaller but I’m still not sure what’s causing it. From what I just tried I’m lead to believe it’s associated with the SQLite node, but I still don’t have enough info to troubleshoot it properly.

0 Likes

#8

Talking with @dceejay, it seems it may be a SQLite node problem. I’ll post back when I have some more info, but I’m interested to see what others are seeing. With a docker container running on Fedora I do not get this error, but on a Raspberry Pi I do (same version of the SQLite node on both 0.2.2).

0 Likes

#9

Interestingly, the npm sqlite3 module Readme states the following.

Supported platforms
The sqlite3 module works with Node.js v4.x, v5.x, v6.x and v7.x.

So no mention of nodejs v8.9.4, which is what you are using… you could try a manual rebuild of the sqlite3 module, using something like npm rebuild sqlite3 --force

0 Likes

#10

Doesn’t seem to have done anything, it finished in less than a second (output below). You may be on to something there though, on my docker image I’m using Node.js v6.13.1 but on the Pi I’m using v8.11.2.

npm WARN using --force I sure hope you know what you are doing.

> sqlite3@4.0.0 install /home/pi/.node-red/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

[sqlite3] Success: "/home/pi/.node-red/node_modules/sqlite3/lib/binding/node-v57-linux-arm/node_sqlite3.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
sqlite3@4.0.0 /home/pi/.node-red/node_modules/sqlite3
0 Likes

#11

I've the same error on one of my rpi:

pi@rpi4:~ $ node-red
12 Dec 12:55:41 - [info] 

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

12 Dec 12:55:41 - [info] Node-RED version: v0.19.5
12 Dec 12:55:41 - [info] Node.js  version: v8.14.0
12 Dec 12:55:41 - [info] Linux 4.14.79-v7+ arm LE
12 Dec 12:55:42 - [info] Loading palette nodes
12 Dec 12:55:51 - [info] Dashboard version 2.12.2 started at /ui
12 Dec 12:55:52 - [info] Settings file  : /home/pi/.node-red/settings.js
12 Dec 12:55:52 - [info] Context store  : 'default' [module=localfilesystem]
12 Dec 12:55:52 - [info] Context store  : 'memoryOnly' [module=memory]
12 Dec 12:55:52 - [info] User directory : /home/pi/.node-red
12 Dec 12:55:52 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
12 Dec 12:55:52 - [info] Flows file     : /home/pi/.node-red/flows_rpi4.json
12 Dec 12:55:53 - [info] Server now running at http://127.0.0.1:1880/
12 Dec 12:55:53 - [info] Starting flows
12 Dec 12:55:56 - [info] Started flows
12 Dec 12:55:56 - [info] [mqtt-broker:325f5be5.555734] Connected to broker: mqtt://xxx.xxx.xxx.xxx:1883
^C
12 Dec 12:55:59 - [info] Stopping flows
12 Dec 12:56:00 - [red] Uncaught Exception:
12 Dec 12:56:00 - Error: write EPIPE
    at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)

I've found some search results for this error:

at WriteWrap.afterWrite [as oncomplete] (net.js:868:14)

but no usable solutions.

Any ideas where net.js is used?

0 Likes

#12

Are you using the SQLite node?

0 Likes

#13

No, my package.json

{
  "dependencies": {
    "node-red-admin": "^0.1.3",
    "node-red-contrib-dht-sensor": "~1.0.3",
    "node-red-contrib-ds18b20-sensor": "^1.3.5",
    "node-red-contrib-dsm": "~0.13.2",
    "node-red-contrib-ibm-watson-iot": "~0.2.8",
    "node-red-contrib-ramp-thermostat": "~0.8.0",
    "node-red-contrib-schedex": "~1.4.1",
    "node-red-dashboard": "~2.12.2",
    "node-red-node-dropbox": "~1.0.2",
    "node-red-node-email": "~1.0.7",
    "node-red-node-pushover": "0.0.13",
    "node-red-node-random": "~0.1.2",
    "node-red-node-rbe": "~0.2.4",
    "node-red-node-serialport": "~0.6.3",
    "node-red-node-smooth": "~0.1.0",
    "node-red-node-suncalc": "0.0.11",
    "request": "^2.88.0"
  }
}
0 Likes

#14

This is mine:

"dependencies": {
    "alasql": "^0.4.11",
    "full-icu": "^1.2.1",
    "ldapauth-fork": "^4.0.2",
    "moment-timezone": "^0.5.23",
    "node-red-contrib-ibm-watson-iot": "^0.2.8",
    "node-red-contrib-lcd20x4-i2c": "0.0.3",
    "node-red-contrib-mssql-ps": "^1.2.5",
    "node-red-contrib-nr-ldapauth": "~1.0.14",
    "node-red-contrib-play-audio": "^2.3.2",
    "node-red-contrib-pn532": "0.0.2",
    "node-red-node-ping": "0.0.15",
    "node-red-node-random": "^0.1.2",
    "node-red-node-serialport": "^0.6.8",
    "node-red-node-smooth": "^0.1.0",
    "node-red-node-sqlite": "~0.3.5"
  }

I'm not actually using node-red-contrib-ibm-watson-iot, node-red-node-random, node-red-node-serialport, or node-red-node-smooth though. I removed all of them and still get the error. My new package.json:

"dependencies": {
    "alasql": "^0.4.11",
    "full-icu": "^1.2.1",
    "ldapauth-fork": "^4.0.2",
    "moment-timezone": "^0.5.23",
    "node-red-contrib-lcd20x4-i2c": "0.0.3",
    "node-red-contrib-mssql-ps": "^1.2.5",
    "node-red-contrib-nr-ldapauth": "~1.0.14",
    "node-red-contrib-play-audio": "^2.3.2",
    "node-red-contrib-pn532": "0.0.2",
    "node-red-node-ping": "0.0.15",
    "node-red-node-sqlite": "~0.3.5"
  }
0 Likes

#15

@cflurin - Did you do a startup and an immediate ctrl-c to stop NR?
What are the flows doing?
Any HTTP nodes being used?

0 Likes

#16
  1. No, I just started node-red in the terminal and used <ctrl-c> to log the error in the terminal.
    It happens also after hours.

  2. Running several flows

  3. http request node

0 Likes

#17

So far I've found net.js is used by node.js.

function afterWrite(status, handle, req, err) {
  var self = handle.owner;
  if (self !== process.stderr && self !== process.stdout)
    debug('afterWrite', status);

  // callback may come after call to destroy.
  if (self.destroyed) {
    debug('afterWrite destroyed');
    return;
  }

  if (status < 0) {
[line 668]    var ex = errnoException(status, 'write', req.error);
    debug('write failure', ex);
    self.destroy(ex, req.cb);
    return;
  }
0 Likes

#18

Does it happen if you use the normal way to start and stop node-red which is node-red-start and node-red-stop?
I wonder whether this is related to the problem with node context not being saved on stopping node-red.

0 Likes

#19

Yes, it does.

You can run/stop node-red using node-red-start and node-red-stop in one terminal.
Open a second terminal and run

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

to display the log.
Probably there are more users facing this error, but they don't see it when stopping node-red.

0 Likes