Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #766
Closed
Open
Issue created Oct 28, 2017 by Administrator@rootContributor

Repeatable jobs failed to end

Created by: ferronrsmith

it('should allow removing a customId repeatable job', function(done){
    var _this = this;
    var date = new Date('2017-02-07 9:24:00');
    this.clock.tick(date.getTime());

    var nextTick = 2 * ONE_SECOND;
    var repeat = {cron: '*/2 * * * * *'};

    queue.add({foo: 'bar'}, {repeat: repeat, jobId : 'xxxx'}).then(function(){
      _this.clock.tick(nextTick);
    });

    queue.process(function(){
      counter ++;
      if(counter == 20){
        return queue.removeRepeatable(_.defaults({jobId:'xxxx'}, repeat)).then(function(){
          setTimeout(done, ONE_SECOND);
          _this.clock.tick(nextTick);
          return null;
        });
      } if (counter > 20){
        done(Error('should not repeat more than 20 times'));
      }
    });

    var prev;
    var counter = 0;
    queue.on('completed', function(job){
      _this.clock.tick(nextTick);
      if(prev){
        expect(prev.timestamp).to.be.lt(job.timestamp);
        expect(job.timestamp - prev.timestamp).to.be.gte(2000);
      }
      prev = job;
    });
  });

Even though the test pass, the repeatable job doesn't actually stop/removed. Might have something to do with the repeatJobId being invalid. Check patch below

Index: lib/repeatable.js
<+>UTF-8
===================================================================
--- lib/repeatable.js	(revision bd14de8adb56fbb153a1cdcb7fe3e47f4c6eeb3c)
+++ lib/repeatable.js	(date 1509169164000)
@@ -53,6 +53,7 @@
   Queue.prototype.removeRepeatable = function(name, repeat){
     var _this = this;
     var repeatJobKey;
+    var repeatJobId;
 
     if(typeof name !== 'string'){
       repeat = name;
@@ -64,8 +65,8 @@
     return this.isReady().then(function(){
       if(!repeatJobKey){
         var jobId = repeat.jobId ? repeat.jobId + ':' : ':';
-        var repeatJobId = getRepeatJobId(name, jobId, '');
         repeatJobKey = getRepeatKey(name, repeat, jobId);
+        repeatJobId = getRepeatJobId(name, jobId, '', md5(repeatJobKey));
       }
       return _this.client.removeRepeatable(_this.keys.repeat, _this.keys.delayed, repeatJobId, repeatJobKey);
     });
Assignee
Assign to
Time tracking