Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
After reading the bot logs using
docker logs binance-bot -f --tail 100
, I see that the bot still has unhandled promise rejection warnings from redlock which may cause the bot to crash or restart the WebSocket.These warnings lead me to do some research, and I found that if any error is thrown inside
callback function
,setInterval
orsetTimeout
will be ignored by the parent try/catch. One solution is to use try/catch inside each block which is hard to do this everywhere. So that's what this pull request is going to solve.I managed to solve this by implementing a global error handler using
process
to handle errors that are not caught by the bot.I know that may catch any unexpected error but this will give us the benefit of handling and debugging any error easily.
Also, this may help us to report any error to any service such as "Sentry" in the future if planned.
Finally,
I don't mind if you do any changes to this pull request.
Any change will be welcomed. Or even if you have a better idea.
How Has This Been Tested?
It was tested locally and test files were also provided