This repository was archived by the owner on Mar 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
Status Code 504 from coinbase causes uncaught error. #55
Copy link
Copy link
Closed
Description
Hey, I'm getting a 504 from Coinbase on a rare occasion and it crashes my stack. Obviously, I could just wrap the call in a try catch but the underlying issue should be fixed.
I ran the request module in debug mode to find find the issue and here's the relevant parts.
REQUEST finish init function https://api.coinbase.com/v2/accounts/<MY UUID>
REQUEST response end https://api.coinbase.com/v2/accounts/<MY UUID> 504 { server: 'cloudflare-nginx',
date: 'Sun, 28 Feb 2016 03:07:39 GMT',
'content-type': 'text/html; charset=UTF-8',
'transfer-encoding': 'chunked',
connection: 'keep-alive',
'set-cookie': [ '__cfduid=aoeu; expires=Mon, 27-Feb-17 03:07:39 GMT; path=/; domain=.coinbase.com; HttpOnly' ],
pragma: 'no-cache',
'x-frame-options': 'SAMEORIGIN',
'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
'cf-ray': '27b8eba251800874-IAD' }
REQUEST end event https://api.coinbase.com/v2/accounts/<MY UUID>
REQUEST has body https://api.coinbase.com/v2/accounts/<MY UUID> 197830
REQUEST emitting complete https://api.coinbase.com/v2/accounts/<MY UUID>
SyntaxError: Unexpected token <
at Object.parse (native)
at handleHttpError (/home/ec2-user/server/node_modules/coinbase/lib/errorHandler.js:43:38)
at Request.onGet [as _callback] (/home/ec2-user/server/node_modules/coinbase/lib/ClientBase.js:155:10)
at Request.self.callback (/home/ec2-user/server/node_modules/coinbase/node_modules/request/request.js:344:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/ec2-user/server/node_modules/coinbase/node_modules/request/request.js:1239:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/ec2-user/server/node_modules/coinbase/node_modules/request/request.js:1187:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
The coinbase-ruby project seemed to have this issue a while back (coinbase/coinbase-ruby#16)
The issue is that at:
https://github.com/coinbase/coinbase-node/blob/master/lib/errorHandler.js#L40, the error case assumes that the content-type is text/json when it's text/html.
I'll probably just submit a pull request to fix this in a few days.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels