Error: Unexpected error while acquiring application default credentials: read ECONNRESET
at /user_code/node_modules/@google-cloud/datastore/node_modules/google-gax/node_modules/google-auth-library/lib/auth/googleauth.js:196:35
at /user_code/node_modules/@google-cloud/datastore/node_modules/google-gax/node_modules/google-auth-library/lib/auth/googleauth.js:229:32
at Request._callback (/user_code/node_modules/@google-cloud/datastore/node_modules/google-gax/node_modules/google-auth-library/lib/transporters.js:79:36)
at self.callback (/user_code/node_modules/@google-cloud/datastore/node_modules/request/request.js:186:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (/user_code/node_modules/@google-cloud/datastore/node_modules/request/request.js:878:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:310:9)"
Environment details
Steps to reproduce
- Attempt to read/write a Datastore entry inside Google Cloud Functions
- Randomly fail (just like the previous issue)
Ah sorry just noticed this. We moved to AppEngine Flex, Go and Spanner and all our issues went away so not sure if this is an issue anymore
@ChrisBartonLC I think you might have a better handle on the status of this issue, as it stands now. Would you catch me up?
Also, thank you for the update and help, @dgadelha!
So we have two service accounts in play, one to talk to GCP resources and one downloaded from the the FB project we use.
so this is the Firebase service account right? AKA Firebase SDK?
log.info(‘Creating firebase app reference’, { context: path(‘app’), fields: { type: type } })
Ah unfortunately that means you will need to embed the service account which is what we do:
client = { datastore: require(‘google-cloud/datastore’)({ credentials: service_account }) }
We actually encrypt our service account with Cloud KMS but I guess you could just include the json in your function as long as your don’t accidentally commit it.
Another option is to temp deploy to Appengine Flex (see below). I though that would be a lot of work but it turned out to be really easy.
app.yaml
app.js
@dgadelha FYI is case you don’t know (or anyone else viewing this), you can pin to these versions as a workaround:
“google-cloud/datastore”: “1.1.0”, “google-cloud/pubsub”: “0.14.0”,
@dgadelha if you are not already a member of the cloud-functions-beta-testers group I recommend you join because there is more up-to-date information of this issue there, see “PubSub subscription stops delivering messages to CloudFunction” which covers both datastore and pubsub, basically it is now reproducible and so no doubt will be fixed in time.