dashpay / platform

L2 solution for seriously fast decentralized applications for the Dash network
https://dashplatform.readme.io/docs/introduction-what-is-dash-platform
MIT License
67 stars 39 forks source link

Dashmate throws SyntaxError on docker 500 #545

Closed pshenmic closed 1 day ago

pshenmic commented 1 year ago

Expected Behavior

Dashmate shows readable error message

Current Behavior

When there is a major issues with Docker (f.e. out of disk memory), dashmate wrongfully parses this response, and failing with SyntaxError: Unexpected token < in JSON at position 0 error.

[STARTED] Force nodes to sync
[DATA] 0.00% complete
SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/Users/ivanshumkov/Projects/dashevo/platform/.yarn/cache/@dashevo-dashd-rpc-npm-2.4.2-60538862a8-fbbb49ed2c.zip/node_modules/@dashevo/dashd-rpc/lib/index.js:128:26)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
<HTML><HEAD>
<TITLE>503 Service Unavailable</TITLE>
</HEAD><BODY>
<H1>Service Unavailable</H1>
</BODY></HTML>

HTTP Status code:503

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^
OperationalError: Dash JSON-RPC: Error Parsing JSON: Unexpected token < in JSON at position 0
    at IncomingMessage.<anonymous> (/Users/ivanshumkov/Projects/dashevo/platform/.yarn/cache/@dashevo-dashd-rpc-npm-2.4.2-60538862a8-fbbb49ed2c.zip/node_modules/@dashevo/dashd-rpc/lib/index.js:133:21)
    ... 2 lines matching cause stack trace ...
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  cause: Error: Dash JSON-RPC: Error Parsing JSON: Unexpected token < in JSON at position 0
      at IncomingMessage.<anonymous> (/Users/ivanshumkov/Projects/dashevo/platform/.yarn/cache/@dashevo-dashd-rpc-npm-2.4.2-60538862a8-fbbb49ed2c.zip/node_modules/@dashevo/dashd-rpc/lib/index.js:133:21)
      at IncomingMessage.emit (node:events:525:35)
      at endReadableNT (node:internal/streams/readable:1358:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21),
  isOperational: true
}

Possible Solution

Catch such errors and provide readable message for the user about the issue

Steps to Reproduce (for bugs)

  1. Make your docker run out of disk memory
  2. dashmate start

Context

Your Environment

shumkov commented 1 day ago

I haven't seen this for a while. @pshenmic and you? I feel like Docker changed the response format. Please reopen if it still the case.