KraigM / homebridge-wink

Wink hub plugin for HomeBridge
54 stars 37 forks source link

Application Error from wink server seems to crash HomeBridge #4

Closed KraigM closed 8 years ago

KraigM commented 8 years ago

I have noticed that occasionally my HomeBridge dies and the only consistent thing is a log of:

SyntaxError: Unexpected token <
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/home/pi/.nvm/versions/node/v0.12.8/lib/node_modules/homebridge-wink/node_modules/wink-js/index.js:62:19)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)
raw message <!DOCTYPE html>
<html>
    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <style type="text/css">
        html, body, iframe { margin: 0; padding: 0; height: 100%; }
        iframe { display: block; width: 100%; border: none; }
      </style>
    <title>Application Error</title>
    </head>
    <body>
      <iframe src="//s3.amazonaws.com/heroku_pages/error.html">
        <p>Application Error</p>
      </iframe>
    </body>
</html>
KraigM commented 8 years ago

After investigating further, the wink-js attempts to parse the error response, fails, catches it, and call callback with null. Our code was not null checking, so it must have crashed.

KraigM commented 8 years ago

Should be fixed by above null check.

Released in 0.0.6