Closed mival closed 2 years ago
Am i right that this only occurs if queue.stop() is called?
Hi, we have similar code to this:
queue.configure({
concurrency: 1,
onQueueFinish: async (tasks) => {
// tasks - here missing failed atribute
const jobs = await queue.getJobs();
if (jobs.length > 0) {
const failedJobIds = jobs.map(item => item.failed && item.id);
// here are failed items correct
}
queue.stop();
queue.removeWorker('offlineRequestsQueueWorker', true);
},
});
if (queue.registeredWorkers.offlineRequestsQueueWorker) {
queue.removeWorker('offlineRequestsQueueWorker', true);
}
queue.addWorker(
new Worker('offlineRequestsQueueWorker', async (payload: any) => {
return new Promise((resolve, reject) => {
// some js fetch with resolve / reject
});
}),
);
You don't have call queue.stop() in onQueueFinish, since the queue is already stopped when the callback is called.
The only case i can find where not all finished tasks would be passed to onQueueFinish would be if the queue is stopped by calling queue.stop(). To fix this i have to kind of queue the stop call until the current running jobs finished.
@SimonErm I have a similar issue with the onFailure
worker callback... the failed
field is empty.
I think it's because this line: https://github.com/SimonErm/react-native-job-queue/blob/c817e6e95e6986f99bd2432285db011b61e0e7fe/src/Queue.ts#L330 is being called before the job has been updated with the proper data
@paulrostorp thank you for the addition, i will take a look at that.
onQueueFinish callback returns empty failed atribute for failed jobs. Calling getJobs after queue finishing returns correct values. Look likes there are some async/timing issues while reading rawJobs value