googleapis / gax-nodejs

Google API Extensions for Node.js
Apache License 2.0
117 stars 87 forks source link

Provide additional call site context when exception originates in gRPC #973

Open bcoe opened 3 years ago

bcoe commented 3 years ago

Errors like RESOURCE_EXHAUSTED to not provide contextual information about where the exception occurs in a user's application:

Error: 8 RESOURCE_EXHAUSTED: Bandwidth exhausted
    at Object.callErrorFromStatus (/root/repo/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Http2CallStream.<anonymous> (/root/repo/node_modules/@grpc/grpc-js/build/src/client.js:96:33)
    at Http2CallStream.emit (events.js:215:7)
    at Http2CallStream.EventEmitter.emit (domain.js:476:20)
    at /root/repo/node_modules/@grpc/grpc-js/build/src/call-stream.js:75:22
    at processTicksAndRejections (internal/process/task_queues.js:75:11) {
  code: 8,
  details: 'Bandwidth exhausted',
  metadata: Metadata { internalRepr: Map {}, options: {} },
  note: 'Exception occurred in retry method that was not classified as transient'
}

It would be nice if we knew the specific method call that triggered exceptions.

Refs: https://github.com/googleapis/nodejs-datastore/issues/525

galaxyfeeder commented 2 months ago

Facing the same issue over here.

Maybe an approach similar to what grpc implemented in https://github.com/grpc/grpc-node/commit/01823377be02b78869c92d8c147944a1b789139b would makes sense for gax.

On our case are calls with Cloud Tasks client. For what I've been able to see, the stack trace could be obtained until this promise at the createApiCall starts executing.

I think the calling context of the stack trace could be stored on the OnGoingCallPromise, then appended to the stack when the rejection function is called.