Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loginAsync crashes when the network is down #82

Open
ELLIOTTCABLE opened this issue Jul 16, 2017 · 3 comments
Open

loginAsync crashes when the network is down #82

ELLIOTTCABLE opened this issue Jul 16, 2017 · 3 comments
Assignees

Comments

@ELLIOTTCABLE
Copy link

I disabled my WiFi to test the behaviour of my tiny script, and I got this:

/Users/ec/Dropbox/Code/generate-tesla-token/node_modules/teslajs/TeslaJS.js:320
        callback(error, { error: error, response: response, body: body, authToken: loginResult.access_token, refreshToken: loginResult.refresh_token });
                                                                                              ^

TypeError: Cannot read property 'access_token' of undefined
    at Request._callback (/Users/ec/Dropbox/Code/generate-tesla-token/node_modules/teslajs/TeslaJS.js:320:95)
    at self.callback (/Users/ec/Dropbox/Code/generate-tesla-token/node_modules/request/request.js:188:22)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at Request.onRequestError (/Users/ec/Dropbox/Code/generate-tesla-token/node_modules/request/request.js:884:8)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at TLSSocket.socketErrorListener (_http_client.js:400:9)
    at emitOne (events.js:115:13)
    at TLSSocket.emit (events.js:210:7)
@mseminatore
Copy link
Owner

Thank you. Yes, the library does not currently test for network connectivity as that is pre-requisite to the libraries function. Is your hope mainly that the library would handle that scenario more gracefully?

@ELLIOTTCABLE
Copy link
Author

Yep! Shouldn't be trying to dereference-undefined when the network is down, basically; throwing a more sensate error is, obviously, about all that is possible. ^_^

@mseminatore
Copy link
Owner

Circling back to review this one. There is no great way to test for network connectivity in Node. Common solution is a DNS resolve request which is noisy on the network. And every single library call requires a working connection to the network. I can look at better error handling if/when an exception occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants