Skip to content

Commit 5fa64c8

Browse files
committed
issue-15 patch and regression test.
1 parent e0556f3 commit 5fa64c8

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Models/Queue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class Queue {
103103
}),
104104
priority: options.priority || 0,
105105
active: false,
106-
timeout: (options.timeout > 0) ? options.timeout : 25000,
106+
timeout: (options.timeout >= 0) ? options.timeout : 25000,
107107
created: new Date(),
108108
failed: null
109109
});

tests/Queue.test.js

+31
Original file line numberDiff line numberDiff line change
@@ -2153,4 +2153,35 @@ describe('Models/Queue', function() {
21532153

21542154
});
21552155

2156+
/**
2157+
*
2158+
* Regression test for issue 15: Indefinite job Timeout is broken
2159+
*
2160+
* https://github.com/billmalarky/react-native-queue/issues/15
2161+
*
2162+
*/
2163+
it('does not override an explicitly set job timeout value of 0 with the default value of 25000.', async () => {
2164+
2165+
const queue = await QueueFactory();
2166+
queue.flushQueue();
2167+
const jobName = 'job-name';
2168+
2169+
// Attach the worker.
2170+
queue.addWorker(jobName, async () => {});
2171+
2172+
// Create a job
2173+
queue.createJob(jobName, { random: 'this is 1st random data' }, {
2174+
timeout: 0
2175+
}, false);
2176+
2177+
// Check that the created job has a timeout value of 0 instead of 25000.
2178+
const jobs = await queue.getJobs(true);
2179+
const job = jobs[0];
2180+
job.timeout.should.equal(0);
2181+
2182+
// Flush jobs
2183+
queue.flushQueue();
2184+
2185+
});
2186+
21562187
});

0 commit comments

Comments
 (0)