node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

node-red-node-pushbullet : Node-Red restart on "TypeError: Cannot read property 'title' of undefined"

Open AlastorPilkine opened this issue 3 years ago • 1 comments

Which node are you reporting an issue on?

  • node-red-node-pushbullet version 0.0.17

What are the steps to reproduce?

  • Don't know if it's possible to reproduce on Node-Red "from scratch"

What happens?

  • Node-red restart when receiving a pushbullet notification. I'm not sure it's on each notification.
  • Log in "/var/daemon.log" are :
Jul 30 12:15:57 localserver Node-RED[115708]: 30 Jul 12:15:57 - [red] Uncaught Exception:
Jul 30 12:15:57 localserver Node-RED[115708]: 30 Jul 12:15:57 - [error] TypeError: Cannot read property 'title' of undefined
Jul 30 12:15:57 localserver Node-RED[115708]:     at PushbulletConfig.pushMsg (/root/.node-red/node_modules/node-red-node-pushbullet/57-pushbullet.js:236:60)
Jul 30 12:15:57 localserver Node-RED[115708]:     at Stream.<anonymous> (/root/.node-red/node_modules/node-red-node-pushbullet/57-pushbullet.js:119:26)
Jul 30 12:15:57 localserver Node-RED[115708]:     at Stream.emit (events.js:400:28)
Jul 30 12:15:57 localserver Node-RED[115708]:     at WebSocket.<anonymous> (/root/.node-red/node_modules/pushbullet/lib/internal/stream.js:54:8)
Jul 30 12:15:57 localserver Node-RED[115708]:     at WebSocket.emit (events.js:400:28)
Jul 30 12:15:57 localserver Node-RED[115708]:     at Receiver.receiverOnMessage (/root/.node-red/node_modules/ws/lib/websocket.js:789:20)
Jul 30 12:15:57 localserver Node-RED[115708]:     at Receiver.emit (events.js:400:28)
Jul 30 12:15:57 localserver Node-RED[115708]:     at Receiver.dataMessage (/root/.node-red/node_modules/ws/lib/receiver.js:422:14)
Jul 30 12:15:57 localserver Node-RED[115708]:     at Receiver.getData (/root/.node-red/node_modules/ws/lib/receiver.js:352:17)
Jul 30 12:15:57 localserver Node-RED[115708]:     at Receiver.startLoop (/root/.node-red/node_modules/ws/lib/receiver.js:138:22)
Jul 30 12:15:58 localserver systemd[1]: Stopped Node-RED graphical event wiring tool.
Jul 30 12:15:58 localserver systemd[1]: Started Node-RED graphical event wiring tool.
Jul 30 12:16:08 localserver Node-RED[298352]: 30 Jul 12:16:08 - [info]
Jul 30 12:16:08 localserver Node-RED[298352]: Welcome to Node-RED
  • previously I only use "pushbullet" node with no trouble on Node-Red stability. Issue appeared since I use "pushbullet in".
  • I add "title" value in every "pushbullet" node I use with no significant impact
  • For exemple, Node-Red crash on Notification from my smartphone

What do you expect to happen?

  • No Node-Red restart

Please tell us about your environment:

  • [x] Node-RED version: v3.0.1
  • [x] node.js version: v14.17.6
  • [x] npm version: 7.24.0
  • [x] Platform/OS: Debian GNU/Linux 11 (bullseye)
  • [x] Browser: Mozilla Firefox Snap for Ubuntu (102.0.1) but probably not concerned.

PS : Thank's for your wonderfull work !

AlastorPilkine avatar Jul 30 '22 11:07 AlastorPilkine

Having the same problem. Uninstalled for now, but would be great if the devs could take a look at this as I have no other way to get SMS in messages to NodeRed for automation processing. Thanks,.

dougle03 avatar Jul 31 '22 13:07 dougle03

I'm having the same issue: I'll use a different notification method for now.

17 Aug 14:24:09 - [error] TypeError: Cannot read properties of undefined (reading 'title') at PushbulletConfig.pushMsg (/config/node-red/node_modules/node-red-node-pushbullet/57-pushbullet.js:236:60) at Stream. (/config/node-red/node_modules/node-red-node-pushbullet/57-pushbullet.js:119:26) at Stream.emit (node:events:527:28) at WebSocket. (/config/node-red/node_modules/pushbullet/lib/internal/stream.js:54:8) at WebSocket.emit (node:events:527:28) at Receiver.receiverOnMessage (/config/node-red/node_modules/pushbullet/node_modules/ws/lib/websocket.js:789:20) at Receiver.emit (node:events:527:28) at Receiver.dataMessage (/config/node-red/node_modules/pushbullet/node_modules/ws/lib/receiver.js:422:14) at Receiver.getData (/config/node-red/node_modules/pushbullet/node_modules/ws/lib/receiver.js:352:17) at Receiver.startLoop (/config/node-red/node_modules/pushbullet/node_modules/ws/lib/receiver.js:138:22) at Receiver._write (/config/node-red/node_modules/pushbullet/node_modules/ws/lib/receiver.js:74:10) at writeOrBuffer (node:internal/streams/writable:389:12) at _write (node:internal/streams/writable:330:10) at Receiver.Writable.write (node:internal/streams/writable:334:10) at TLSSocket.socketOnData (/config/node-red/node_modules/pushbullet/node_modules/ws/lib/websocket.js:864:35) at TLSSocket.emit (node:events:527:28) [14:24:09] WARNING: Node-RED crashed, halting add-on [14:24:09] INFO: Node-RED stoped, restarting... s6-rc: info: service legacy-services: stopping [14:24:09] INFO: Node-RED stoped, restarting... s6-svwait: fatal: supervisor died

T2evh avatar Aug 17 '22 15:08 T2evh

Hi @dougle03, @T2evh

which version of the pushbullet node are you using ? The weird thing is the lines mentioned in the error don't seem to match anything useful in latest source. image

Can you copy those relevant lines here so i can try to match them up (lines 236 and 119) Thanks

dceejay avatar Aug 19 '22 09:08 dceejay

At a guess, @dougle03 mentions SMS and line 224 in the code looks like it could definitely throw that error...

https://github.com/node-red/node-red-nodes/blob/c1c82a623e01992e2862d68e65fcc306dd9bcdd1/social/pushbullet/57-pushbullet.js#L224

incoming.notifications[0] is not sanity checked before accessing .title and .body

Steve-Mcl avatar Aug 19 '22 11:08 Steve-Mcl

Hi @dougle03, @T2evh

which version of the pushbullet node are you using ? The weird thing is the lines mentioned in the error don't seem to match anything useful in latest source. image

Can you copy those relevant lines here so i can try to match them up (lines 236 and 119) Thanks

I'm using version 0.0.17. I'll attempt to look up the lines of code later today. Thanks for your help

T2evh avatar Aug 19 '22 11:08 T2evh

I'm using version 0.0.17. I'll attempt to look up the lines of code later today.

No need really - you are already on the latest version (same as master branch - see here)

Steve-Mcl avatar Aug 19 '22 12:08 Steve-Mcl

For background information. I'm using Node Red with Home Assistant (home automation software). I use node red for scripting alerts, such as post arrived or car charged etc. I thought I'd disabled every pushbullet node, but looks like I missed one. So far node red has not crashed yet. I can look at enabling one node at a time to see which scenario is causing the crash

T2evh avatar Aug 19 '22 12:08 T2evh

Ah right yes sms... Any chance either of you could add a line before the one Steve mentions (224) to be

console.log("INCOMING:",incoming);
msg.topic = "SMS: "+ incoming.notifications[0].title; 

So we can see what that incoming message really looks like ? in the log

Easy enough to stop it failing but would rather try to d something sensible if we can...

dceejay avatar Aug 19 '22 14:08 dceejay

Ah right yes sms... Any chance either of you could add a line before the one Steve mentions (224) to be

console.log("INCOMING:",incoming);
msg.topic = "SMS: "+ incoming.notifications[0].title; 

So we can see what that incoming message really looks like ? in the log

Easy enough to stop it failing but would rather try to d something sensible if we can...

Yes happy to help, but you could you provide the path of the module you want me to edit. I assume its somewhere below node-red/node_modules/pushbullet?

Thanks Trevor

T2evh avatar Aug 19 '22 14:08 T2evh

Most likely userDir/node_modules/node-red-node-pushbullet where userDir is logged early in the Node-RED startup (looks like /.node-red from the earlier comments)

hardillb avatar Aug 19 '22 15:08 hardillb

OK console added to code, but on my code it's line 236. Not sure why if we are on same version 0.0.17,but thought I'd flag it, in case relevant. It may be a few hours before it crashes

image

T2evh avatar Aug 19 '22 15:08 T2evh

Yes correct. We sit and await.

dceejay avatar Aug 19 '22 15:08 dceejay

I don’t use SMS in my scripts. I use push notifications to my devices. I've run a few pushbullet notifications script's in node red but don't see those in the log. I'm no expert but it may not be specific to SMS. I'll look to add more log lines to the java.

T2evh avatar Aug 19 '22 17:08 T2evh

OK its crashed and here is the log...

INCOMING: { type: 'sms_changed', source_device_iden: 'ujCbp1WR3Cusjw1nY709wO', notifications: [] } 20 Aug 11:10:02 - [red] Uncaught Exception: 20 Aug 11:10:02 - [error] TypeError: Cannot read properties of undefined (reading 'title') at PushbulletConfig.pushMsg (/config/node-red/node_modules/node-red-node-pushbullet/57-pushbullet.js:237:60) at Stream. (/config/node-red/node_modules/node-red-node-pushbullet/57-pushbullet.js:119:26) at Stream.emit (node:events:527:28)

T2evh avatar Aug 20 '22 11:08 T2evh

Pushed a fix as version 0.0.19 please check and let us know . Thanks for your help.

dceejay avatar Aug 20 '22 17:08 dceejay