mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 21:30:30 +01:00
refactor: catch errors from digest
This commit is contained in:
@@ -38,6 +38,7 @@ Digest.execute = async function (payload) {
|
||||
winston.info(`[user/jobs] Digest (${payload.interval}) complete.`);
|
||||
} catch (err) {
|
||||
winston.error(`[user/jobs] Could not send digests (${payload.interval})\n${err.stack}`);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,13 +39,17 @@ module.exports = function (User) {
|
||||
function startDigestJob(name, cronString, term) {
|
||||
jobs[name] = new cronJob(cronString, (async () => {
|
||||
winston.verbose(`[user/jobs] Digest job (${name}) started.`);
|
||||
if (name === 'digest.biweekly') {
|
||||
const counter = await db.increment('biweeklydigestcounter');
|
||||
if (counter % 2) {
|
||||
User.digest.execute({ interval: term });
|
||||
try {
|
||||
if (name === 'digest.biweekly') {
|
||||
const counter = await db.increment('biweeklydigestcounter');
|
||||
if (counter % 2) {
|
||||
await User.digest.execute({ interval: term });
|
||||
}
|
||||
} else {
|
||||
await User.digest.execute({ interval: term });
|
||||
}
|
||||
} else {
|
||||
User.digest.execute({ interval: term });
|
||||
} catch (err) {
|
||||
winston.error(err.stack);
|
||||
}
|
||||
}), null, true);
|
||||
winston.verbose(`[user/jobs] Starting job (${name})`);
|
||||
|
||||
Reference in New Issue
Block a user