better-queue
Advanced tools
Comparing version 3.8.11 to 3.8.12
@@ -620,2 +620,3 @@ var uuid = require('uuid'); | ||
self._failedTotal++; | ||
self._retries[taskId] = undefined | ||
self.emit('task_failed', taskId, msg, stats); | ||
@@ -622,0 +623,0 @@ } else { |
{ | ||
"name": "better-queue", | ||
"version": "3.8.11", | ||
"version": "3.8.12", | ||
"description": "Better Queue for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "lib/queue.js", |
@@ -84,2 +84,32 @@ var assert = require('assert'); | ||
it('should retry jobs with same id', function (done) { | ||
const maxRetries = 3 | ||
const getJob = (id = 1) => ({ id, attempt: 0 }) | ||
const q = new Queue((job, cb) => { | ||
job.attempt++ | ||
cb(job) | ||
}, { maxRetries }) | ||
let job = getJob(1) | ||
q.push(job) | ||
.on('failed', err => { | ||
assert.equal(err.id, job.id) | ||
assert.equal(err.attempt, maxRetries) | ||
job = getJob(2) | ||
q.push(job) | ||
.on('failed', err => { | ||
assert.equal(err.id, job.id) | ||
assert.equal(err.attempt,maxRetries) | ||
job = getJob(1) | ||
q.push(job) | ||
.on('failed', err => { | ||
assert.equal(err.id, job.id) | ||
assert.equal(err.attempt, maxRetries, 'job with id 1 shall fail after maxRetries') | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
it('should fail retry', function (done) { | ||
@@ -86,0 +116,0 @@ var tries = 0; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79808
2056