googleapis / googleapis/google-cloud-node

createTask is not returning response

Open
#4,579 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

I invoke my function createUploadTask simultaneously about 200 times and it works properly in the field of creating tasks in queue(the tasks are also finished correctly), but the problem occurs while waiting for the response. My code just freezes and nothing is happening because it is waiting for the promise in createTask to resolve, what never happens.

Here is my code:

```javascript
const createUploadTask = async (filename: string, bucket: string, contentType: string, data: any) => {
const payload = {
filename,
bucket,
contentType,
data,
};

const url = `${process.env.GCLOUD_FUNCTIONS_URL}/uploadToCS`;

const task = {
httpRequest: {
httpMethod: google.cloud.tasks.v2beta3.HttpMethod.POST,
url,
headers: {
"Content-Type": "application/json",
},
oidcToken: {
serviceAccountEmail: email,
audience: url,
},
body: Buffer.from(JSON.stringify(payload)).toString("base64"),
},
dispatchDeadline: { seconds: 60 },
};

const request = { parent, task };
const [response] = await client.createTask(request);

const name = response.name ?? "name not exists";

return name;
};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.