hjespers / node-red-contrib-nest

Node-Red module for Nest thermostats and smoke detectors
20 stars 15 forks source link

TypeError: Cannot read property 'toString' of undefined #4

Closed scottsweb closed 7 years ago

scottsweb commented 8 years ago

Started seeing frequent crashes today, logs are:

5 Feb 18:11:21 - TypeError: Cannot read property 'toString' of undefined
    at Request._callback (/home/scott/.node-red/node_modules/node-red-contrib-nest/nest/nest.js:96:49)
    at self.callback (/home/scott/.node-red/node_modules/node-red-contrib-nest/node_modules/request/request.js:198:22)
    at Request.emit (events.js:107:17)
    at Request.onRequestError (/home/scott/.node-red/node_modules/node-red-contrib-nest/node_modules/request/request.js:820:8)
    at ClientRequest.emit (events.js:107:17)
    at TLSSocket.socketOnEnd (_http_client.js:300:9)
    at TLSSocket.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)

Will do some investigation to see if I can find out what has changed.

JonMurphy commented 8 years ago

scott - I just realized I opened an issue (#5) just like this. Were you able to determine what had changed? Jon

scottsweb commented 7 years ago

@JonMurphy afraid not. I am finding node red crashes quite a bit still and it is no longer logging properly either. I need to spend some more time investigating.

hjespers commented 7 years ago

Finally getting back to working on this. I can reproduce the problem.

JonMurphy commented 7 years ago

Excellent!

hjespers commented 7 years ago

The problem has to do with getting responses from nest with null values. I'm trying out some simple changes and doing better exception handling. Put the fixes on github but not yet published to npm.

JonMurphy commented 7 years ago

Hans - since I know little to nothing about npm, I am guessing I cannot test until it is published on npm and I can install it within node-red. If this is incorrect please let me know.

hjespers commented 7 years ago

This should be fixed in version 0.1.9. When the node received null data responses it was still trying to convert the response to a string, hence the uncaught exception.

If you reinstall "sudo npm install -g node-red-contrib-nest" it should install the latest version.

Streaming mode still has some issues but the regular mode should work fine and not crash node-red when it encounters errors.