zenbot icon indicating copy to clipboard operation
zenbot copied to clipboard

Crash when unable to get the account balance.

Open carlospaulino opened this issue 4 years ago • 3 comments

System information

  • Have I written custom code (as opposed to using zenbot vanilla): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS Big Sur 11.4
  • Zenbot version (commit ref, or version): 5df014ad2c47a2218cbe7fb85d56b5732dbb260f
  • Zenbot branch: unstable
  • NodeJS version: v15.2.1
  • Exact command to reproduce (include everything): ./zenbot.sh trade kraken.xeth-zusd --deposit 1000 --strategy dema --period 1h

Describe the problem

Sometimes, when the bot tries to get the latest balance from Kraken, the connection times out. When this happens, the bot crashes because the syncBalance function tries to destructure the quote property from an undefined value. So far, I've noticed that this only occurs when connected to Kraken.

Source code / Error logs

getBalance error:
RequestError: Timeout awaiting 'request' for 5000ms
    at ClientRequest.<anonymous> (/path/zenbot/node_modules/got/dist/source/core/index.js:956:65)
    at Object.onceWrapper (node:events:436:26)
    at ClientRequest.emit (node:events:341:22)
    at ClientRequest.origin.emit (/path/zenbot/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
    at TLSSocket.socketErrorListener (node:_http_client:478:9)
    at TLSSocket.emit (node:events:329:20)
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:80:21)
    at Timeout.timeoutHandler [as _onTimeout] (/path/zenbot/node_modules/got/dist/source/core/utils/timed-out.js:36:25)
    at listOnTimeout (node:internal/timers:558:17)
    at processTimers (node:internal/timers:499:7) {
  name: 'TimeoutError',
  code: 'ETIMEDOUT',
  timings: {
    start: 1626104365616,
    socket: 1626104365616,
    lookup: 1626104365617,
    connect: undefined,
    secureConnect: undefined,
    upload: undefined,
    response: undefined,
    end: undefined,
    error: 1626104370617,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 1,
      tcp: undefined,
      tls: undefined,
      request: undefined,
      firstByte: undefined,
      download: undefined,
      total: 5001
    }
  },
  event: 'request'
}
/path/zenbot/lib/engine.js:378
    syncBalance(function (err, { quote }) {
                                 ^

TypeError: Cannot destructure property 'quote' of 'undefined' as it is undefined.
    at /path/zenbot/lib/engine.js:378:34
    at /path/zenbot/lib/engine.js:224:23
    at /path/zenbot/extensions/exchanges/kraken/exchange.js:155:18
    at /path/zenbot/node_modules/kraken-api/kraken.js:176:23
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)

carlospaulino avatar Jul 12 '21 22:07 carlospaulino

I am going to open a PR to address this issue.

carlospaulino avatar Jul 12 '21 22:07 carlospaulino

Can i work on this issue?

Ayush-projects avatar Aug 17 '21 17:08 Ayush-projects

Can I work on this issue?

Of course, I've been swamped by work and haven't got the chance to address this issue.

carlospaulino avatar Aug 17 '21 19:08 carlospaulino