blinktrade / BlinkTradeJS

BlinkTrade JavaScript SDK and CLI
GNU General Public License v3.0
122 stars 46 forks source link

UnhandledPromiseRejectionWarning: Unhandled promise rejection #35

Closed helxsz closed 6 years ago

helxsz commented 6 years ago
blinktrade.connect().then(function() {
    return blinktrade.login({ username: config.key, password: config.password });
}).then(function(logged) {
    console.log("Connected BlinkTradeWS")
})

My node is v8.9.4 and npm 5.6.0, and I am using the latest version of BlinkTrade, when I was running the code, i got the error as shown below.

(node:9502) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): undefined
(node:9502) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
hadnet commented 6 years ago

Same here, but it happened once, now when I try to connect again I got this:

/Users/inc/Desktop/Foxbit/node_modules/blinktrade/lib/wsTransport.js:163 throw new Error('Error: ' + data.Detail + ' ' + data.Description); ^

Error: Error: Invalid message Invalid message at BlinkTradeWS.onMessage (/Users/inc/Desktop/Foxbit/node_modules/blinktrade/lib/wsTransport.js:163:15) at WebSocket.onMessage (/Users/inc/Desktop/Foxbit/node_modules/ws/lib/EventTarget.js:99:16) at WebSocket.emit (events.js:160:13) at Receiver._receiver.onmessage (/Users/inc/Desktop/Foxbit/node_modules/ws/lib/WebSocket.js:141:47) at Receiver.dataMessage (/Users/inc/Desktop/Foxbit/node_modules/ws/lib/Receiver.js:389:14) at Receiver.getData (/Users/inc/Desktop/Foxbit/node_modules/ws/lib/Receiver.js:330:12) at Receiver.startLoop (/Users/inc/Desktop/Foxbit/node_modules/ws/lib/Receiver.js:165:16) at Receiver.add (/Users/inc/Desktop/Foxbit/node_modules/ws/lib/Receiver.js:139:10) at TLSSocket._ultron.on (/Users/inc/Desktop/Foxbit/node_modules/ws/lib/WebSocket.js:138:22) at TLSSocket.emit (events.js:160:13)

cesardeazevedo commented 6 years ago

@helxsz We were under maintenance this week, it was expected since our servers were off.

@hadnet Does it still happen? i can't reproduce it with this code

const { BlinkTradeWS } = require('blinktrade')

const blinktrade = new BlinkTradeWS({
  brokerId: 4,
  prod: true,
})

blinktrade.connect().then(() => {
  console.log('connected')
})
hadnet commented 6 years ago

@cesardeazevedo it does. But it happens when I try to send a buy/sell order.

cesardeazevedo commented 6 years ago

@hadnet i gotcha, i've fixed and release at 0.0.20.

Let me know if you guys have any other issue.

hadnet commented 6 years ago

@cesardeazevedo same as the error above, just this line changed: BlinkTradeWS.onMessage (/Users/inc/Desktop/Foxbit/node_modules/blinktrade/lib/wsTransport.js:164:15) [in error above was 163:15]. It seems something with cancel or update.

cesardeazevedo commented 6 years ago

@hadnet I can't help you without a minimum information and way that i could reproduce it, what exactly you are trying to do? which part the exception occur? which function are you calling? can you post a small code that i could take a look?

hadnet commented 6 years ago

@cesardeazevedo Now it's suddenly working ok. Thanks anyway.