google-auth-library-nodejs: cloud-function error: Could not load the default credentials

I’m currently seeing sporadic errors, in multiple Firebase Cloud Functions, with the following stack:

Error: Unexpected error while acquiring application default credentials: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.
    at GoogleAuth.<anonymous> (/user_code/node_modules/@google-cloud/firestore/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:249:31)
    at step (/user_code/node_modules/@google-cloud/firestore/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:47:23)
    at Object.next (/user_code/node_modules/@google-cloud/firestore/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:28:53)
    at fulfilled (/user_code/node_modules/@google-cloud/firestore/node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7)

I know this shouldn’t happen, because default credentials should work in a cloud function (and it does sometimes, but also sometimes produces errors).

TL;DR; I think I’m using 1.3.1 (see below for explanation for why I’m not sure), and if so, I don’t think the problem is actually in this library, it’s more likely in gcp-metadata. But the way this library is using gcp-metadata the original error is suppressed.

If nobody know what’s causing this, you could use gcpMetadata.instance() instead of gcpMetadata.isAvailable(), which would give you access to the error object.


More info:

I’m struggling to properly track the source of the problem due to me using yarn workspaces in a multi-module project, my functions are just one module, so when it gets uploaded to GCP it’s running npm install without a lock file.

I think it’s using 1.3.1 but I’m struggling to prove it. I’ve spun up a Cloud Shell and downloaded the storage object for my cloud function and ran npm install and I don’t get google-auth-library in the same path as shown in the stacktrace. Instead of it being nested as @google-cloud/firestore -> google-gax -> google-auth-library, it’s being nested as google-gax -> google-auth-library, so although it’s likely my function is using 1.3.1, I’m not 100% certain.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Just to chime in, I was seeing the same thing in firebase functions, but haven’t seen it since 2nd of August.

screen shot 2018-08-07 at 13 15 11

screen shot 2018-08-07 at 13 15 03

screen shot 2018-08-07 at 13 14 50