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
71 stars 39 forks source link

Error logging & unhandled promise rejection #126

Open riongull opened 4 years ago

riongull commented 4 years ago

Expected Behavior

Rightly or not, I didn't expect console logs from the production release of DashJS. Instead, I expected all errors to just be thrown, allowing the consumer of the library to choose how to handle them.

Current Behavior

There are 4 instances where DashJS logs console.errors to the consumer. There are also others in DashJS dependancies, such as the 18 instances in wallet-lib.

Issue dashevo/js-dash-sdk#54 occasionally results in a long error like this:

Failed to get dataContract { Error: 14 UNAVAILABLE: failed to connect to all addresses
    at Object.exports.createStatusError (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:1209:28)
    at InterceptingListener._callNext (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:618:8)
    at InterceptingListener._callNext (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:574:12)
    at InterceptingListener.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:847:24)
  code: 14,
  metadata: Metadata { _internal_repr: {}, flags: 0 },
  details: 'failed to connect to all addresses' }
SDK apps fetching : failed to init { Error: 14 UNAVAILABLE: failed to connect to all addresses
    at Object.exports.createStatusError (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:1209:28)
    at InterceptingListener._callNext (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:618:8)
    at InterceptingListener._callNext (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:574:12)
    at InterceptingListener.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:847:24)
  code: 14,
  metadata: Metadata { _internal_repr: {}, flags: 0 },
  details: 'failed to connect to all addresses' }
(node:25756) UnhandledPromiseRejectionWarning: Error: 14 UNAVAILABLE: failed to connect to all addresses
    at Object.exports.createStatusError (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/common.js:91:15)
    at Object.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:1209:28)
    at InterceptingListener._callNext (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:568:42)
    at InterceptingListener.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:618:8)
    at InterceptingListener._callNext (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:574:12)
    at InterceptingListener.onReceiveStatus (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:618:8)
    at callback (/Users/Rion/code/dash/playground/basic-ts/node_modules/grpc/src/client_interceptors.js:847:24)
(node:25756) 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: 1)
(node:25756) [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.
error: Error fetching UTXO yXZHE87HnZzM9RdE29A9k4ChtNXnxsBH1b,yPywTqhYdTShcVGjdUvZ7oEVrDtLMuvmHd,yZy99o1pA5rLeJUAW8KT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Veq9qTZVEjtT4HaSDGf,yZdgtKRTDVg9B9zzXr4FsET9pTtmC69kDk,yUFZCSEwQdZciXHpLYmc2B3VjmFCv6uYGk,ychK67wjRkoTNaVm7tV4jF3bXAifRfrNVA,yZF2yumqwL1oLK64VyKau1v7d7q54YS2Md,yNuRJoysLAiAp8rueyHX1pf7n6iYriXYec,yLPG4U83w4Ete45EJJwsEe5x6tJeMcoEj8,ySwfbguagCc8vYpsTbEmS6rDf9Yo2jiMKZ,ygwF4LkjBY79YBHUxKpJBuiSd33P6s48bk:{_from}:{_to} - connect ETIMEDOUT 159.89.8.31:3000
(node:25756) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT 159.89.8.31:3000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
(node:25756) 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: 3)
error: Error fetching UTXO yXZHE87HnZzM9RdE29A9k4ChtNXnxsBH1b,yPywTqhYdTShcVGjdUvZ7oEVrDtLMuvmHd,yZy99o1pA5rLeJUAW8KTn9L7orb4ENUgoD,yhbgMHneshPk9AGkFKNuRXL9LEWzzoyAn7,yZqgZBEQx7LWW86hbrpHRjTsWKGJQMmXmt,yPDnxrjVXZXPXYp93huz8gj54wBvVnj16W,yaacFqcTTjzqfmzhE8TCTjpDfxB1VvrpqZ,ySfb5jSAyJgLaNL59dHmYhYGDcFa22ZMYw,ycHJ3cwn9UqdsqEBmJjU1PvGjX5WfPkVgV,yb97wbMADJ6xNu47dXpn5z9MQsmxxTEcf2,yULX46SvfWs9oVBBiRU8poCya1X55EoUqT,yYRMM4jpwrygyLC53B9XH4EuUPPUoTpy6f,ybVYawJ4XCvA6EDgiSyGkXBq6qN5VSVXvb,yR1qxxgtZFPnsvyjJkdzkZZkNf1BuJKYHu,yiiPLJbLppSf6EixjrcCMd4ZefZcvEfJcb,yahrxZx5aYsyDbypMiAbmPFV43XfoVBfBJ,yXVuuMPbw6snFrTgKbRZipg9UGNYnpKXrK,ybsX3WTYpbTgqbUavsiAd7WLCDSMNxzJib,yZa6ejoJWvr2oUqj4QQfJBKctZxf7aR98t,yfVR4Pwxbp2LUpmJ64A36GGe6Bs5ivfc9m,yMZvb8zaTtWwRqSLHNdXSE9CjhtTTZSpEx,yPer3w7GwWTwVbd2M5gwZbREsrndrjC4ju,yPkZFARXSXU8XPum5o6Mk81dvzvWERd7PF,yMjyCvtAQxxFJVWGTVUknT2umTKWLxoHPt,yPkxnnztuhhYyYT6zXkUmvASKPWXn191vr,yMxRiDUDPqp51D9eTAtSPpCtJrqcB7p5Mg,yNyC1poPe45FTkmtqTARekKkyYDEG8FPZD,ygAPvEiexcD3LrXXUUwUTk6BrDswJDz6JP,yYN7vnouqqiNnWYZJZsvxAcUUGoxYqAh1d,yierSZ7DzRjLyjP8WN5NLoziwCxCUCtV39,yQWUynQhD2PHRWzgUN45rKRdYkNkBhUK38,yWZqHvAJLp77fdApxCpRTn7fz1V8EuMhvn,yMp8yTcVsLGWmfRwwPDyDtdKqwCqQRgrZe,yhArTHM1Zge816QVeq9qTZVEjtT4HaSDGf,yZdgtKRTDVg9B9zzXr4FsET9pTtmC69kDk,yUFZCSEwQdZciXHpLYmc2B3VjmFCv6uYGk,ychK67wjRkoTNaVm7tV4jF3bXAifRfrNVA,yZF2yumqwL1oLK64VyKau1v7d7q54YS2Md,yNuRJoysLAiAp8rueyHX1pf7n6iYriXYec,yLPG4U83w4Ete45EJJwsEe5x6tJeMcoEj8,ySwfbguagCc8vYpsTbEmS6rDf9Yo2jiMKZ,ygwF4LkjBY79YBHUxKpJBuiSd33P6s48bk:{_from}:{_to} - connect ETIMEDOUT 159.89.8.31:3000
(node:25756) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT 159.89.8.31:3000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
(node:25756) 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: 5)
(node:25756) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT 159.89.8.31:3000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
(node:25756) 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: 7)
error: Error fetching UTXO yXZHE87HnZzM9RdE29A9k4ChtNXnxsBH1b,yPywTqhYdTShcVGjdUvZ7oEVrDtLMuvmHd,yZy99o1pA5rLeJUAW8KTn9L7orb4ENUgoD,yhbgMHneshPk9AGkFKNuRXL9LEWzzoyAn7,yZqgZBEQx7LWW86hbrpHR...

... (keeps adding "error: Error fetching UTXO"s and uncaught promise rejection warnings)

This is two errors in a row from dash (Failed to get dataContract and SDK apps fetching : failed to init), followed by an error from wallet-lib (error: Error fetching UTXO) that repeats until you send a SIGINT with control+c. Interwoven in the repeated Error fetching UTXO error are a bunch of uncaught promise rejections. I'm not sure, but I think this is being caused by the dash code/process, not my code. - I'm handling/catching errors correctly as far as I know).

The errors above aren't the issue here, that's covered in dashevo/js-dash-sdk#54. I'm just using them for illustration regarding error handling and logging in general. My two specific questions are:

  1. Are there any uncaught errors in dash and/or its dependencies as the errors above might suggest, and
  2. Should we be logging errors in Dash libraries, or would it be better to just throw them for the consumer to catch and handle as they wish?

I'm also wondering if the rationale for logging errors in addition to throwing them might be to see something more than a stack trace full of grpc references, which leaves out relevant detail of where the error(s) originate.

Personally I prefer not to have errors logged in libraries; I'd rather have them thrown for me to catch and handle. The UnhandledPromiseRejectionWarnings made me think there was something wrong with my code for a long time, and I'm wondering if maybe that's not the case after all.

Context & Reproduction

The errors above can be reproduced as described in dashevo/js-dash-sdk#54, but it's better to run the code without any automatic script restarts like --watch or --respawn so that you can see that the process doesn't quit on its own, even though it should.

antouhou commented 4 years ago

Yep, that's absolutely true. We'll work on that

shumkov commented 1 month ago

I guess it's still true