google-cloud-node icon indicating copy to clipboard operation
google-cloud-node copied to clipboard

Provide better error message when projectId is not available

Open ofrobots opened this issue 7 years ago • 0 comments

I'm using the sample app for logging-bunyan, but I expect this to happen across the board across all libraries.

> node server.js

(node:38767) UnhandledPromiseRejectionWarning: Error: Sorry, we cannot connect to Cloud Services withouta project
 ID. You may specify one with an environment variable named
 "GOOGLE_CLOUD_PROJECT".
    at replaceProjectIdToken (node_modules/@google-cloud/projectify/build/src/index.js:45:19)
    at Object.replaceProjectIdToken (node_modules/@google-cloud/projectify/build/src/index.js:38:30)
    at self.auth.getProjectId (node_modules/@google-cloud/logging/build/src/index.js:719:40)
    at getProjectIdAsync.then.r (node_modules/google-auth-library/build/src/auth/googleauth.js:73:48)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
(node:38767) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated eitherby throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 13)
(node:38767) [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.

Problems:

  1. Unhandled rejection warnings are bad. They suggest that we are missing error handling somewhere. We need to holistically ensure that we do not throw unhandled rejections in the Node.js client libraries.
  2. As a result the error message is not very useful at pointing out where the root cause of the problem occurred. It would be good for the error message to ultimately point back to my code where I made a call that required credentials that ended up erroring.

ofrobots avatar Dec 13 '18 19:12 ofrobots