Node-red-contrib-meross crashing node-red

I installed the meross node to control some MSS310 plugs. I followed all instructions and got the token and IP of the plug (which is connected, pings fine, and is controlled well by the app). Issue is, when try to send msg.payload TRUE to the node, the node-red server crashes and restarts with this error log:

13 Jan 01:08:55 - [red] Uncaught Exception:
13 Jan 01:08:55 - [error] SyntaxError: Unexpected token P in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request._callback (/home/pi/.node-red/node_modules/node-red-contrib-meross/meross/smartplug-control.js:68:19)
    at self.callback (/home/pi/.node-red/node_modules/request/request.js:185:22)
    at Request.emit (node:events:517:28)
    at Request.emit (node:domain:489:12)
    at Request.<anonymous> (/home/pi/.node-red/node_modules/request/request.js:1154:10)
    at Request.emit (node:events:517:28)
    at Request.emit (node:domain:489:12)
    at IncomingMessage.<anonymous> (/home/pi/.node-red/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (node:events:631:28)
    at IncomingMessage.emit (node:events:529:35)
    at IncomingMessage.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1400:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.

node-red version 3.1.3
node-red-contrib-meross 2.2.1
Node.js v18.19.0
Running on a Raspberry Pi 4B with OS Debian GNU/Linux 12 (bookworm)

Any help appreciated

It looks like the node is getting a non JSON response then tries to parse it into an object but it does not have suitable error handling and therefore crashes node-red.

In short, a node package should handle all errors (especially in async/callback code)

You should raise a new issue here: Issues · dehsgr/node-red-contrib-meross · GitHub and provide the stack trace and a link back to this post for x-ref

1 Like