add 20x delay when search results in an error

This commit is contained in:
2017-05-23 20:16:05 -07:00
parent 4813c5bfa3
commit bb898e26c2

View File

@@ -256,7 +256,8 @@ export default class Worker extends events.EventEmitter {
}
this._poller.timer = setTimeout(() => {
this._getPendingJobs().then((jobs) => {
this._getPendingJobs()
.then((jobs) => {
if (!this._poller.running) return;
const foundJobs = (!jobs || jobs.length === 0);
@@ -266,6 +267,16 @@ export default class Worker extends events.EventEmitter {
this._poller.running = false;
this._startJobPolling();
});
}, () => {
// if the search failed for some reason, back off the polling
// we assume errors came from a busy cluster
// TODO: check what error actually happened
const multiplier = 20;
setTimeout(() => {
this._poller.running = false;
this._startJobPolling();
}, this.checkInterval * multiplier);
});
} , this.checkInterval);