Fix Cannot read property 'statusCode' of undefined when updating and there's no connection
Before:
$ node index.js update
Checking for updates...
No update available. You have the latest version: 1.4.1
------------------------------------------------------------------
Uncaught Error: TypeError: Cannot read property 'statusCode' of undefined
at Request.request.get [as _callback] (/Users/ernest.iliiasov/logdna/logdna-cli/lib/utils.js:175:55)
at self.callback (/Users/ernest.iliiasov/logdna/logdna-cli/node_modules/request/request.js:185:22)
at Request.emit (events.js:189:13)
at Request.onRequestError (/Users/ernest.iliiasov/logdna/logdna-cli/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:194:15)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
------------------------------------------------------------------
$ logdna update
Checking for updates...
No update available. You have the latest version: 1.4.1
After
$ logdna update
Checking for updates...
No update available. You have the latest version: 1.4.1
No update available. You have the latest version: 1.4.1
Fix
Cannot read property 'statusCode' of undefined
when updating and there's no connectionBefore:
After:
Prevent calling callback twice
Before:
After