Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Error handling Binance API response #1673

Closed
ansonphong opened this issue Jan 12, 2018 · 4 comments
Closed

Error handling Binance API response #1673

ansonphong opened this issue Jan 12, 2018 · 4 comments

Comments

@ansonphong
Copy link
Contributor

ansonphong commented Jan 12, 2018

Note: for support questions, please join our Discord server

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository

  • Action taken (what you did)
    Occurred while running a live trader on Binance.

  • Expected result (what you hoped would happen)

  • Actual result (unexpected outcome)

After running smooth for about an hour, this error happened and Node crashed:

2018-01-12 10:55:23 (DEBUG):    Requested XRP/BTC trade data from Binance ...
C:\...\gekko\exchanges\binance.js:62
    if(!_.isEmpty(body.code)) {
                       ^

TypeError: Cannot read property 'code' of undefined
    at C:\...\gekko\exchanges\binance.js:62:24
    at Request.request [as _callback] (C:\...\gekko\node_modules\binance\lib\rest.js:66:21)
    at self.callback (C:\...\gekko\node_modules\request\request.js:188:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (C:\...\gekko\node_modules\request\request.js:884:8)
    at emitOne (events.js:121:20)
    at ClientRequest.emit (events.js:211:7)
    at TLSSocket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc)

I think this could be due to the Binance API call giving an undefined response, we might want to first check that the body is defined before processing it.

@ipansensoy
Copy link

is there any update about this error?

@cmroche
Copy link
Contributor

cmroche commented Jan 12, 2018

It's possible that the Binance module changed something about their error handling again, I'll check it out over the weekend.

If that is the case, running npm install [email protected] should work around the issue for now.

@cmroche
Copy link
Contributor

cmroche commented Jan 12, 2018

Ok actually this was simpler than that, a missing null check. I'll push a fix shortly.

@ansonphong
Copy link
Contributor Author

ansonphong commented Jan 13, 2018

Thanks @cmroche, yes that's how I ended up fixing it locally.

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

No branches or pull requests

3 participants