From 046535397a2cf9c20d4c5897c70ab4337e4956fb Mon Sep 17 00:00:00 2001 From: Cameron Paczek Date: Wed, 15 Feb 2023 12:33:32 -0800 Subject: [PATCH] Change removal logic --- packages/core/strapi/lib/services/cron.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/strapi/lib/services/cron.js b/packages/core/strapi/lib/services/cron.js index 8561cbc2a4..7d1dab4698 100644 --- a/packages/core/strapi/lib/services/cron.js +++ b/packages/core/strapi/lib/services/cron.js @@ -28,8 +28,8 @@ const createCronService = () => { const fnWithStrapi = (...args) => fn({ strapi }, ...args); - const job = new Job(null, fnWithStrapi); - jobsSpecs.push({ job, options }); + const job = new Job(taskValue.name || null, fnWithStrapi); + jobsSpecs.push({ job, options, name: taskValue.name }); if (running) { job.schedule(options); @@ -38,9 +38,9 @@ const createCronService = () => { return this; }, remove(name) { - const matchingJobsSpecs = jobsSpecs.filter(({ options }) => options.name === name); + const matchingJobsSpecs = jobsSpecs.filter(({ name: jobSpecName }) => jobSpecName === name); matchingJobsSpecs.forEach(({ job }) => job.cancel()); - jobsSpecs = jobsSpecs.filter(({ options }) => options.name !== name); + jobsSpecs = jobsSpecs.filter(({ name: jobSpecName }) => jobSpecName !== name); return this; }, start() {