logdna / logdna-cli

The LogDNA CLI allows you to signup for a new account and tail your server logs right from the command line.
https://logdna.com
MIT License
27 stars 21 forks source link

Fix `Cannot read property 'statusCode' of undefined` when updating #40

Closed ernestii closed 4 years ago

ernestii commented 5 years ago

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)
------------------------------------------------------------------

After:

$ node index.js update
Checking for updates...
Error [no response]: Error: getaddrinfo ENOTFOUND repo.logdna.com repo.logdna.com:443

Prevent calling callback twice

Before:

$ 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
smusali commented 4 years ago

Done, @ydshah2!