server: only decrement deletion ref count on final fail

Changelog: Fixed
This commit is contained in:
Johann150 2024-01-24 01:15:36 +01:00
parent 83bce62672
commit aac1c40657
Signed by: Johann150
GPG Key ID: 9EE6577A2A06F8F1
1 changed files with 5 additions and 1 deletions

View File

@ -59,7 +59,11 @@ deliverQueue
})
.on('failed', async (job, err) => {
deliverLogger.warn(`failed(${err}) ${getJobInfo(job)} to=${job.data.to}`);
await deletionRefCount(job);
if (job.attemptsMade >= (job.opts?.attempts ?? 1)) {
// this was the last attempt
await deletionRefCount(job);
}
})
.on('error', (job: any, err: Error) => deliverLogger.error(`error ${err}`))
.on('stalled', (job) => deliverLogger.warn(`stalled ${getJobInfo(job)} to=${job.data.to}`));