mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
Added catch for cron error (#8864)
* Added catch for cron error * Updated logger usage
This commit is contained in:
committed by
Sabe Jones
parent
7a2432a1a0
commit
28b56256d2
@@ -5,6 +5,7 @@ import { model as Group } from '../models/group';
|
||||
import { model as User } from '../models/user';
|
||||
import { recoverCron, cron } from '../libs/cron';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import logger from '../libs/logger';
|
||||
|
||||
async function cronAsync (req, res) {
|
||||
let user = res.locals.user;
|
||||
@@ -106,13 +107,17 @@ async function cronAsync (req, res) {
|
||||
|
||||
await recoverCron(recoveryStatus, res.locals);
|
||||
} else {
|
||||
logger.error(err, {isUserUpdateErroringDuringCron: true});
|
||||
// For any other error make sure to reset _cronSignature so that it doesn't prevent cron from running
|
||||
// at the next request
|
||||
await User.update({
|
||||
_id: user._id,
|
||||
}, {
|
||||
_cronSignature: 'NOT_RUNNING',
|
||||
}).exec();
|
||||
}).exec()
|
||||
.catch((newError) => {
|
||||
logger.error(newError, {isUserUpdateErroringDuringCron: true});
|
||||
});
|
||||
|
||||
throw err; // re-throw the original error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user