googleapis / googleapis/google-cloud-node
createTask is not returning response
- 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
Assessment
This issue has not been assessed yet.