[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createTask is not returning response #4579

Open
majkelEXE opened this issue Aug 23, 2023 · 0 comments
Open

createTask is not returning response #4579

majkelEXE opened this issue Aug 23, 2023 · 0 comments

Comments

@majkelEXE
Copy link

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:

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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant