googleapis / nodejs-datastore

Node.js client for Google Cloud Datastore: a highly-scalable NoSQL database for your web and mobile applications.
https://cloud.google.com/datastore/
Apache License 2.0
214 stars 106 forks source link

Improve how errors are reported - better stack traces, exceptions #926

Open glowforge-opensource opened 2 years ago

glowforge-opensource commented 2 years ago

Hi! This is definitely a feature request to get more visibility into what is going wrong when using the NodeJS Datastore client library.

Is your feature request related to a problem? Please describe.

At various points using the library (using async/await semantics), we've had issues where errors would be thrown. However, our application is fairly large so it can be hard to tell from the stack traces where things are going awry – or even what underlying Datastore API is being handled. For example, this is what one recent production Datastore exception gives us (@google-cloud/datastore version 6.6.2):

"Error: 14 UNAVAILABLE: read ECONNRESET
    at Object.callErrorFromStatus (/webpack:/path-to-our-app/node_modules/@grpc/grpc-js/build/src/call.js:31:1)
    at Object.onReceiveStatus (/webpack:/path-to-our-app/node_modules/@grpc/grpc-js/build/src/client.js:180:1)
    at Object.onReceiveStatus (/webpack:/path-to-our-app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:1)
    at Object.onReceiveStatus (/webpack:/path-to-our-app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:1)
    at /webpack:/path-to-our-app/node_modules/@grpc/grpc-js/build/src/call-stream.js:182:1
    at processTicksAndRejections (internal/process/task_queues.js:77:11)"

Additionally, almost all exceptions thrown by the Datastore client are type Error. There is no way to catch Datastore specific exceptions except to ensure any calls to it are very closely enclosed in try/catch and wrapped with another exception.

Describe the solution you'd like

Some or all of the following would be nice:

We have mitigated the client throwing bare Error by wrapping all call sites with our own exception. Note the issue is not that the exception is being thrown, bu that it's fairly non-trivial to figure out what call point it's happening from and whether we need to change anything to address it.

Thank you! Rachael Ludwick (from Glowforge)

kirillgroshkov commented 7 months ago

That would be fantastic to address

udnes99 commented 7 months ago

Please prioritize getting this done. It is extremely frustrating and hard at times to debug when using Datastore extensively throughout our code.