Open skymakerolof opened 11 months ago
I'm facing the same issue , and it happens when you call longRunningOperation.promise()
I'm still trying to find the reason
Found a workaround by using the https://www.npmjs.com/package/googleapis package instead. Something like this should work:
const googleAuth = new google.auth.GoogleAuth({
keyFile: 'path/to/keyFile',
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
})
const cloudfunctions = google.cloudfunctions({
version: 'v1',
auth: googleAuth,
})
const functions = cloudfunctions.projects.locations.functions
const operations = cloudfunctions.operations
const functionOperationResponse = functions.create({ location, requestBody })
let operationResponse
for (let i = 0; i <= 60; i++) {
operationResponse = await operations.get({
name: functionOperationResponse.data.name,
})
if (operationResponse.data.done) break
await new Promise((r) => setTimeout(r, 3000))
}
When programmatically creating a cloud function, I get the error "3 INVALID_ARGUMENT: Invalid resource field value in the request." when awaiting the long-running operation using the provided
promise()
call as described in the sample code. I can see that the cloud function is actually created correctly in the Google Cloud Console, so the problem appears to only relate to checking the status of the operation.Environment details
Steps to reproduce
Create a file
debug.js
with the content below. Make sure to update the variablesprojectId
,location
andkeyFilePath
with valid values. Add required dependencies withnpm install @google-cloud/functions got jszip
.Execute
debug.js
with NodeJS: