Bad node error - crashes Node-Red

#1

Node-red crushes every time when I disconnect SDA or SCL from I2C device. It's very inconvenient, maybe somebody knows how to receive an error instead of a full system crash?

20 Oct 17:26:53 - Error: EREMOTEIO: remote I/O error, write
at Object.fs.writeSync (fs.js:735:20)
at Bus.i2cWriteSync (/home/pi/.node-red/node_modules/i2c-bus/i2c-bus.js:348:13)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.

#8

@iungo the error is coming from the i2c-bus module. Node-RED doesn't use that module - one of the nodes you've installed uses that module. The length of the ads1x15 node code is irrelevant - in fact, because its so short, it could well be missing the proper error handling it should have.

But a quick dig into the modules shows node-red-contrib-oled depends on the i2c-bus that is throwing the error - so the fault is definitely the error handling in the oled module.

#9

Ok, I understand it.

But does node-red has any error handling? If it has proper error handling why it crashes and restarts?

#10

This is an uncaught asynchronous error. We do catch it, but because we have no way of knowing where it has come from (because it is an async error), the only safe option we have is to shutdown the runtime as it is in an unknown state.

I'll refer you to node's own documentation on this class of error - https://nodejs.org/api/process.html#process_warning_using_uncaughtexception_correctly - in particular:

Attempting to resume normally after an uncaught exception can be similar to pulling out of the power cord when upgrading a computer — nine out of ten times nothing happens - but the 10th time, the system becomes corrupted.