TeamWertarbyte / crypto-trading-bot

A trading bot that does what you order him to do (use at your own risk)
MIT License
30 stars 18 forks source link

Unexpected token warning? #13

Open IHateNameStealers opened 3 years ago

IHateNameStealers commented 3 years ago

ichimoku was running fine for 2 days now (in a screen), but all of a sudden I got the following error/warning due to an Unexpected token from https://api.bittrex.com/v3/markets/KNC-EUR/ticker

As far as I can see there is nothing wrong with KNC EUR

See log report below.

[13:01:41] ########## Started ichimoku ########## [13:02:01] Collected revenue 19403.45975 ms [13:02:01] Fetched 664 and filtered 21 EUR markets 42.75964 ms [13:02:01] Fetched 664 and filtered 17 market summaries 71.74199 ms [13:02:28] Evaluated 17 markets in total 27427.01933 ms [13:02:38] Called report webhook [13:02:38] ########## Finished 56787.74028 ms ########## [13:05:38] ########## Started ichimoku ########## (node:6969) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at https://api.bittrex.com/v3/markets/KNC-EUR/ticker reason: Unexpected token < in JSON at position 0 at /home/bot/node_modules/node-fetch/lib/index.js:272:32 at process._tickCallback (internal/process/next_tick.js:68:7) (node:6969) 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: 2) (node:6969) [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.

saschb2b commented 3 years ago

Thanks for the report. I really have to add more debugging logs to better resolve those issues. Market looks also fine to me. Will see if I can reproduce it

IHateNameStealers commented 3 years ago

Another error today.

[03:21:58] ########## Started ichimoku ########## (node:4402) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at https://api.bittrex.com/v3/balances reason: Unexpected token < in JSON at position 0 at /home/bot/node_modules/node-fetch/lib/index.js:272:32 at process._tickCallback (internal/process/next_tick.js:68:7) (node:4402) 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: 2) (node:4402) [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.

saschb2b commented 3 years ago

Thanks for the additional report. That seems like a connection issue rather than an issue bittrex wise. (because it's another endpoint now) I will check what happens when my internet is flaky.

For the time being: Currently your bot just crashes will not restart. You can install forever https://www.npmjs.com/package/forever This will restart a js application if it's crashed automatically. Assuming a restart will just fix your issue. Build the bot via yarn build and then use the installed forever package to start the builded js application forever start dist/index.js See the forever documentation on how to stop and get logs.

saschb2b commented 3 years ago

Related: https://github.com/node-fetch/node-fetch/issues/620

saschb2b commented 3 years ago

This should not happen anymore when we've migrated to websockets see #37