-
Notifications
You must be signed in to change notification settings - Fork 2k
Error: Cannot read property 'toString' of undefined #457
Comments
What was the command you were trying to run? |
Zenbot trade bittrex.USDT-BCC --period=5m |
I have the same problem, it occurs randomly on some bots once every several hours. undefined /home/admin/zenbot_xrp/node_modules/numbro/numbro.js:1111 TypeError: Cannot read property 'toString' of undefined |
I made this go away by adding this line above node_modules/numbro/numbro.js:1111
|
Seems that testing for falsy wasn't enough so ...
maybe??? |
Undefined and null are both already falsey in JS. |
Can we fix this with a pull request |
Same here, the error occurs randomly on Bittrex, if (!x) return 1; solved it for now. |
This error is happening because the value for 's.balance.asset' is undefined, on (presently) lines 140 and 244 of trade.js. For posterity and clarity's sake, here is that line: I verified this with a small test program in node...
If you run that program, any value you pass in will be successful, except for an 'undefined' for the 'asset' variable. In that failing case, the resulting exception matches our situation here. This variable is likely being set incorrectly somewhere in the Bittrex exchange object, when engine.js makes a call to Bittrex exhange's getBalance() method, from the engine.js :: syncBalance() method, currently on line 184. But I'm not 100% on that. Regardless it seems like some bad data may be coming from the API. To fix it, we should wrap the call that sets tmp_balance, in trade.js, in a method and ensure that s.balance.asset is not undefined, otherwise set it to 0, before making the call. That will prevent the exception. Once I get home this evening, I will make a PR for this... |
I already have a PR in for the numbro repository owned by carlos8f. See: Fix Issue #457 for Zenbot Repository If that is merged, then the The package.json is pointing to that version of numbro. This seems to be a very reliable fix. Is there anyone that can approve that pull request? |
@KryptoNova Agreed. I think that is a clean fix. |
I'm not sure, but if @DeviaVir could approve the pull request mentioned at Fix Issue #457 for Zenbot Repository then we should be in business. @DeviaVir, If this cannot be done, let me know. I do have a Plan B if you do not have the ability to approve those pull requests. |
@KryptoNova unfortunately I don't have the permissions. Want me to fork it and we'll use that fork instead? edit: forked to https://github.com/highvelocityspace/numbro |
v4.0.5
The text was updated successfully, but these errors were encountered: