From d000ff9387d8e83aa5a27e78d56b6b29180bf4bb Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Wed, 14 Dec 2022 04:40:19 +0000 Subject: [PATCH] fix: tweaks from testing Signed-off-by: Brent Hoover --- packages/api-plugin-bull-queue/src/api/createQueue.js | 3 ++- packages/api-plugin-bull-queue/src/api/scheduleJob.js | 2 +- .../api-plugin-promotions/src/watchers/setPromotionState.js | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/api-plugin-bull-queue/src/api/createQueue.js b/packages/api-plugin-bull-queue/src/api/createQueue.js index 9fbf9469cbf..765dd6228a8 100644 --- a/packages/api-plugin-bull-queue/src/api/createQueue.js +++ b/packages/api-plugin-bull-queue/src/api/createQueue.js @@ -63,7 +63,8 @@ export default function createQueue(context, queueName, options = defaultOptions }); newQueue.on("failed", (job, err) => { - Logger.error({ ...err, ...logCtx }, "Job process failed"); + const error = JSON.stringify(err); + Logger.error({ error, ...logCtx }, "Job process failed"); }); return newQueue; } diff --git a/packages/api-plugin-bull-queue/src/api/scheduleJob.js b/packages/api-plugin-bull-queue/src/api/scheduleJob.js index b6a78bca254..4f6ce624f7d 100644 --- a/packages/api-plugin-bull-queue/src/api/scheduleJob.js +++ b/packages/api-plugin-bull-queue/src/api/scheduleJob.js @@ -23,7 +23,7 @@ const logCtx = { * @return {Boolean} - true if success */ export default async function scheduleJob(context, queueName, jobName, jobData, schedule) { - if (typeof jobData !== "object" || typeof schedule !== "string") { + if (typeof jobData !== "object" || typeof schedule !== "string" || typeof queueName !== "string" || typeof jobName !== "string") { Logger.error(logCtx, "Invalid parameters supplied to scheduleJob"); return false; } diff --git a/packages/api-plugin-promotions/src/watchers/setPromotionState.js b/packages/api-plugin-promotions/src/watchers/setPromotionState.js index 8677dbc9ee7..cf2d3506e09 100644 --- a/packages/api-plugin-promotions/src/watchers/setPromotionState.js +++ b/packages/api-plugin-promotions/src/watchers/setPromotionState.js @@ -36,9 +36,11 @@ async function markActive(context) { ] }).toArray(); for (const promotion of toMarkActive) { - const { modifiedCount } = Promotions.updateOne({ _id: promotion._id }, { $set: { state: "active" } }); + // eslint-disable-next-line no-await-in-loop + const { modifiedCount } = await Promotions.updateOne({ _id: promotion._id }, { $set: { state: "active" } }); if (modifiedCount === 1) { appEvents.emit("promotionActivated", promotion); + Logger.info({ promotionId: promotion._id, ...logCtx }, "Promotion made active"); totalUpdated += 1; } else { Logger.error({ promotionId: promotion._id, ...logCtx }, "Error updating promotion record to active");