From 2e4cb7f4b08c5475f757ea7810796ad6ce8b79ad Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 29 Aug 2022 12:01:17 +0800 Subject: [PATCH] Fix using wrong taskHandlerUrl for low priority task --- packages/api/src/utils/createTask.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/api/src/utils/createTask.ts b/packages/api/src/utils/createTask.ts index c4de5d58b..962b796ee 100644 --- a/packages/api/src/utils/createTask.ts +++ b/packages/api/src/utils/createTask.ts @@ -45,11 +45,7 @@ const createHttpTaskWithToken = async ({ ] > => { // Construct the fully qualified queue name. - if (priority === 'low') { - queue = `${queue}-low` - // use GCF url for low priority tasks - taskHandlerUrl = env.queue.contentFetchGCFUrl - } + priority === 'low' && (queue = `${queue}-low`) const parent = client.queuePath(project, location, queue) console.log(`Task creation options: `, { @@ -240,10 +236,17 @@ export const enqueueParseRequest = async ( return '' } + // use GCF url for low priority tasks + const taskHandlerUrl = + priority === 'low' + ? env.queue.contentFetchGCFUrl + : env.queue.contentFetchUrl + const createdTasks = await createHttpTaskWithToken({ project: GOOGLE_CLOUD_PROJECT, payload, priority, + taskHandlerUrl, }) if (!createdTasks || !createdTasks[0].name) { logger.error(`Unable to get the name of the task`, { @@ -357,9 +360,6 @@ export const enqueueTextToSpeech = async ({ bucket, textType, } - if (priority === 'low') { - queue = `${queue}-low` - } // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const token = await signToken({ uid: userId }, env.server.jwtSecret, {