firebase queue - retries are not working?

337 Views Asked by At

Trying to figure out how to make retries work.

this is how my FB queue looks :

{
  "specs" : {
    "default_spec" : {
      "retries" : 3,
      "timeout" : 60000
    }
  },
  "tasks" : {

  }
}

and this is how I'm testing if retries work:

const queue = new Queue(getFirebaseRef(),{'numWorkers': 10} , function (data, progress, resolve, reject) {
        console.log('processing queue message:' + JSON.stringify(data));
        progress(50);

        setTimeout(()=>{
            reject(new Error("error while processing blabla"));

        },2000);
    });

so when I push new task to queue , this is how it looks after being processed by my worker :

{
  "-KcsTIDBAq1S_fdiwsv6" : {
    "_error_details" : {
      "attempts" : 1,
      "error" : "error while processing blabla",
      "error_stack" : "Error: error while processing blabla\n    at Timeout.setTimeout ...,
      "previous_state" : "in_progress"
    },
    "_progress" : 50,
    "_state" : "error",
    "_state_changed" : 1487089675432,
    "body" : {
      "testing" : "this_is_a_test_task"
    }
  }
}

so I would expect attempts to be 3 , I also have no indication in the service that 3 tasks were handled.

Question is , how can I get the retries to work. worth mentioning that this is what I did after reading documentation

2

There are 2 best solutions below

0
On BEST ANSWER

Eventually it was a combination of what @Caerbannog wrote and adding the default_spec in code instead of directly inserting it in Firebase console.

so to recap those were my changes :

var options = {
    'specId': "default_spec",
    'numWorkers': 10

};

and

var queueRef = getFirebaseRef();
var specs = {
    "default_spec": {
        "start_state": null,
        "in_progress_state": "in_progress",
        "finished_state": null,
        "error_state": "error",
        "timeout": 60000,
        "retries": 50
    }
};
queueRef.child('specs').set(specs);
1
On

Your default_spec is currently useless. You need to add this second line in the queue options :

{
  'numWorkers': 10,
  'specId': "default_spec"
}

Please read the following firebase-queue issue:

https://github.com/firebase/firebase-queue/issues/106#issuecomment-279975546