From b7853323ae2269222787dd03809c0333d540fb2f Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 27 Jul 2022 15:12:52 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20email=20sending=20job=20?= =?UTF-8?q?execution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://github.com/TryGhost/Toolbox/issues/359 - Sending newsletters got broken because underlying "inline job" execution had a bug. - The real problem was in the job manager trying to verify inline unnamed job status in the database without having a name. --- ghost/job-manager/lib/job-manager.js | 2 +- ghost/job-manager/test/job-manager.test.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ghost/job-manager/lib/job-manager.js b/ghost/job-manager/lib/job-manager.js index c3e754b6c0..7e9878c04e 100644 --- a/ghost/job-manager/lib/job-manager.js +++ b/ghost/job-manager/lib/job-manager.js @@ -81,7 +81,7 @@ class JobManager { } async _jobMessageHandler({name, message}) { - if (this._jobsRepository) { + if (this._jobsRepository && name) { if (message === 'started') { const job = await this._jobsRepository.read(name); diff --git a/ghost/job-manager/test/job-manager.test.js b/ghost/job-manager/test/job-manager.test.js index 94d44fdbd1..b6b04ce0dd 100644 --- a/ghost/job-manager/test/job-manager.test.js +++ b/ghost/job-manager/test/job-manager.test.js @@ -33,7 +33,9 @@ describe('Job Manager', function () { describe('Inline jobs', function () { it('adds a job to a queue', async function () { const spy = sinon.spy(); - const jobManager = new JobManager({}); + const jobManager = new JobManager({ + JobModel: sinon.stub().resolves() + }); jobManager.addJob({ job: spy,