I'm getting an issue from the title with the full error log here:
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.getApplicationDefaultAsync (/workspace/node_modules/google-auth-library/build/src/auth/googleauth.js:159:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
I know,there are multiple questions about that already:
- Firebase Functions: Could not load default credentials
- Could not load the default credentials. Firebase and Express error
- Firebase Server error: 'Could not load the default credentials'
But none actually solve the issue fully. Things we've tried (multiple people in my office, multiple environments, multiple projects, so it's not a single issue):
- Deployed as node 8, or node 10, which is recommended as of couple of days ago
- Redeploy of functions
- Initalizing the app with or without config object (
admin.initializeApp();
) - Function must return a value or a promise
- Assigning
firebase-adminsdk
as a service account to the function in the GCP - Updated firebase-tools and firebase-adminsdk to latest versions
It happens in all versions of firebase functions, onCall, onRequest, scheduled functions...
Any of the remedies tried above sometimes fix stuff, sometimes not, it's definitely not end-all-bug fix in either case.
What bugs me the most is the latest example where I've had a function fail and then took these steps:
- Function was deployed with Node 8, updated, and started to fail.
- I've tried just redeploying the function - nothing.
- I've tried redeploying as Node 10 - nothing.
- I've entered Google Cloud Platform, found the function and changed permission to
firebase-adminsdk
which sometimes helped - not this time. - I've deleted the function from the list, and redeployed identical function - everything works fine.
This tells me that there is a serious issue with permissions regarding the account that actually executes the functions, since it sometimes works, sometimes not. Usually it breaks after an update to already existing function, and usually it works after deleting and redeploying an old function for "the first time".
This is not really acceptable in later stages of a live project where stuff fails with no explanation or at least without a reproducible issue. This is not documented in any guides, all fixes provided on the Stack Overflow or elsewhere are either short term solutions or fixed for a specific case, but the error that is thrown shows up sooner or later again.
What am I missing? The rest of the Firebase is perfect and always consistent, but this is getting ridiculous. Thanks for the help everyone.