Bittrex tries to access this._subCount when sub/unsub but its undefined, throws error
See original GitHub issueccxws v 0.27.2
Exchange Bittrex
Subscription type level2 orderbook updates
Describe the bug
It looks like the Bittrex client is trying to access the internal this._subCount
property but it’s undefined
(perhaps it needs to be bound for the correct this
).
Bittrex ccxws websocket error: No Hub
Cannot read property 'BTC-EOS' of undefined
at BittrexClient._sendSub (/home/evan/devel/coygo/webapp/.meteor/desktop-build/node_modules/ccxws/src/exchanges/bittrex-client.js:126:48)
at BittrexClient._subscribe (/home/evan/devel/coygo/webapp/.meteor/desktop-build/node_modules/ccxws/src/exchanges/bittrex-client.js:108:14)
at BittrexClient.subscribeLevel2Updates (/home/evan/devel/coygo/webapp/.meteor/desktop-build/node_modules/ccxws/src/exchanges/bittrex-client.js:82:10)
at classDefinition.(anonymous function).registerOrderBookListener (/home/evan/devel/coygo/webapp/.meteor/desktop-build/desktop.asar/trading/exchange-clients/ExchangeClientCcxtCcxwsCommon.js:177:16)
at process._tickCallback (internal/process/next_tick.js:68:7)
TypeError: Cannot read property 'BTC-EOS' of undefined
at BittrexClient._sendUnsub (/home/evan/devel/coygo/webapp/.meteor/desktop-build/node_modules/ccxws/src/exchanges/bittrex-client.js:150:20)
at BittrexClient._unsubscribe (/home/evan/devel/coygo/webapp/.meteor/desktop-build/node_modules/ccxws/src/exchanges/bittrex-client.js:119:14)
at BittrexClient.unsubscribeLevel2Updates (/home/evan/devel/coygo/webapp/.meteor/desktop-build/node_modules/ccxws/src/exchanges/bittrex-client.js:90:10)
at classDefinition.(anonymous function).deregisterOrderBookListener (/home/evan/devel/coygo/webapp/.meteor/desktop-build/desktop.asar/trading/exchange-clients/ExchangeClientCcxtCcxwsCommon.js:363:16)
(node:10161) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
The problem lines are:
_sendSub(remote_id) {
// increment market counter
this._subCount[remote_id] = (this._subCount[remote_id] || 0) + 1;
_sendUnsub(remote_id) {
// decrement market count
this._subCount[remote_id] -= 1;
}
To Reproduce Subscribe to l2 updates on Bittrex BTC-EOS market.
This happened once but I can’t reproduce it since then, so I just grabbed the logs to place them here in hopes that it’s enough details.
Expected behavior Connection is successful and doesn’t throw error.
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Troubleshooting common error codes - Bittrex Support
The code you entered has either expired or is invalid. Please wait for a new code on your device and try your submission...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Two fixes are now available in release v0.27.3:
Most likely the second is the culprit of your issues. The calls to subscribe were checking for the existence of the websocket variable
_wss
https://github.com/altangent/ccxws/blob/22eafc7fc5330a7fac75be7cf62a4602a390f7c0/src/exchanges/bittrex-client.js#L118 to determine if it is ok to immediately send a subscription to the server._wss
is created in_connect
https://github.com/altangent/ccxws/blob/22eafc7fc5330a7fac75be7cf62a4602a390f7c0/src/exchanges/bittrex-client.js#L191However,
_subCount
does not get set until a valid connection is established with the handler_onConnected
.This opened a window where a subscription would think the websocket was open when it was not actually open yet and when the call stack
subscribeLevel2Update
>_subscribe
>_sendSub
> occurred without actually be connected it would abend.A new flag has been added
_isConnected
that gets set when the connection handler_onConnected
is fired and is unset when disconnected event is fired in_onDisconnected
. This flag is now checked in the subscribe method to determine if an immediate subscription can be performed.I’m going to close this issue for now, if you’re still seeing the issue after this fix then we can reopen it.
@evan-coygo v0.27.3 should be live on NPM now