Skip to content

Commit ec9cc57

Browse files
committed
fix(queue): respect maxRetries: 0 in job retry configuration
Closes #3
1 parent 9661af4 commit ec9cc57

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/queue_manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ class QueueManagerSingleton {
286286
const queueRetryConfig = queueConfig?.retry || {}
287287

288288
let maxRetries =
289-
jobRetryConfig?.maxRetries ||
290-
queueRetryConfig.maxRetries ||
291-
this.#globalRetryConfig?.maxRetries ||
289+
jobRetryConfig?.maxRetries ??
290+
queueRetryConfig.maxRetries ??
291+
this.#globalRetryConfig?.maxRetries ??
292292
0
293293

294294
let backoff =

tests/queue_manager.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,23 @@ test.group('QueueManager', () => {
113113
assert.equal(config.maxRetries, 2)
114114
})
115115

116+
test('should respect maxRetries: 0 from job config over global/queue config', async ({
117+
assert,
118+
}) => {
119+
await QueueManager.init({
120+
default: 'sync',
121+
adapters: { sync: sync() },
122+
locations: ['./examples/jobs/**/*'],
123+
retry: { maxRetries: 5, backoff: exponentialBackoff() },
124+
queues: {
125+
email: { retry: { maxRetries: 3 } },
126+
},
127+
})
128+
129+
let config = QueueManager.getMergedRetryConfig('email', { maxRetries: 0 })
130+
assert.equal(config.maxRetries, 0)
131+
})
132+
116133
test('should throw E_QUEUE_NOT_INITIALIZED when use() called before init()', async ({
117134
assert,
118135
}) => {

0 commit comments

Comments
 (0)