DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.23k stars 2.03k forks source link

Handle GDAX "API down for maintenance" gracefully #1257

Open haxwell opened 6 years ago

haxwell commented 6 years ago

System information

Describe the problem

At the moment, the GDAX API is down for maintainence. If you inspect the node gdax exchange module you can see that a message is returned saying as much. We should display that message.

break in node_modules/gdax/lib/orderbook_sync.js:90
 88 
 89     function onData(data) {
>90       debugger
 91       this.books[productID].state(data);
 92 
debug> exec data
{ message: 'GDAX is currently under maintenance. For updates please see https://status.gdax.com/' }
debug> 

Source code / logs

After running the backfill command, in the console we see

websocket connection to BTC-USD opened
Error: Failed to load orderbook: Cannot read property 'map' of undefined
    at OrderbookSync.onError (/home/jjames/src/zenbot.haxwell/zenbot/node_modules/gdax/lib/orderbook_sync.js:96:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
^C

and then it hangs. We should catch the error that happens on the creation of the Orderbook object (currently line 23 in the websocketClient() method of gdax/exchange.js) and gracefully fail, displaying the message to the client.

To reproduce this, (since, once the API comes back up, this error won't occur), replace the Gdax.OrderbookSync() call with a module that throws an exception when created. It will be the same effect for the purposes of this issue.

cpjolicoeur commented 6 years ago

I'd be glad to try to tackle this and submit a PR if no one is on it yet. Just say the word.

cpjolicoeur commented 6 years ago

Actually, I think this could be handled by simply updating the version of the gdax npm package we lock to. This appears to have been fixed in their repository already via this commit: 20d1292

DeviaVir commented 6 years ago

I think there was an issue with updating, perhaps you could look into that if you are interested?

krystophv commented 6 years ago

If only they'd release a new version to NPM instead of letting commits just sit on their master branch for a month