mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Fixed an unhandled exception in job manager
closes https://github.com/TryGhost/Toolbox/issues/402 - The SQL error was thrown whenever a job error was happening and was trying to persist an error. Persisting an error should only happen for "named" one-off jobs, instead of just one-off jobs.
This commit is contained in:
parent
b3a33760ac
commit
54c19226bf
2 changed files with 9 additions and 2 deletions
|
@ -114,7 +114,7 @@ class JobManager {
|
|||
}
|
||||
|
||||
async _jobErrorHandler(error, jobMeta) {
|
||||
if (this._jobsRepository) {
|
||||
if (this._jobsRepository && jobMeta.name) {
|
||||
const job = await this._jobsRepository.read(jobMeta.name);
|
||||
|
||||
if (job) {
|
||||
|
|
|
@ -65,7 +65,12 @@ describe('Job Manager', function () {
|
|||
|
||||
it('handles failed job gracefully', async function () {
|
||||
const spy = sinon.stub().throws();
|
||||
const jobManager = new JobManager({});
|
||||
const jobModelSpy = {
|
||||
findOne: sinon.spy()
|
||||
};
|
||||
const jobManager = new JobManager({
|
||||
JobModel: jobModelSpy
|
||||
});
|
||||
|
||||
jobManager.addJob({
|
||||
job: spy,
|
||||
|
@ -81,6 +86,8 @@ describe('Job Manager', function () {
|
|||
should(spy.called).be.true();
|
||||
should(spy.args[0][0]).equal('test data');
|
||||
should(logging.error.called).be.true();
|
||||
// a one-off job without a name should not have persistance
|
||||
should(jobModelSpy.findOne.called).be.false();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue