SimonErm / react-native-job-queue

Easy to use react-native queuing library
https://simonerm.github.io/react-native-job-queue/
122 stars 33 forks source link

[FIX] Mark active but timed out jobs as failed #25

Closed hannojg closed 3 years ago

hannojg commented 4 years ago

Following use case:

Without the fixes in this PR however, the job would never get restarted and still be marked as active forever in the database. The implementation in this PR mark the jobs that are active but considered timed out as failed, so that when the queue starts the job can be retried.

maybe we should add a note to the docs, that the jobs should be idempotent, like here.

I also updated the UI of the example app. To reproduce the issue:

  1. Start the example app
  2. Click on the second button (which says that it will create a job with a timeout)
  3. Click on "Start queue" and close the app immediately (swiping it away)
  4. Reopen the app, and click on "Start queue" You will see that the queue picks up the job (which failed) and will restart it, and thus increases the counter.

This PR also exposes two other issues:

  1. In Promise.race the executer promise doesn't get cancelled which can lead to strange results
  2. I set the job to have 2 attempts. However, the lib runs the job 3-4 times. These issues should be fixed in another PR:
SimonErm commented 4 years ago

First of all that's a exemplary PR description :+1: :-). The changes look good to me so far, just the marked function should be renamed since the naming could be missleading.

I think maybe we should mark all jobs as failed which are active before the queue is started in future. But this can be done in another PR.

SimonErm commented 3 years ago

closed because of https://github.com/SimonErm/react-native-job-queue/pull/27