Skip to content

Commit

Permalink
Fixed an issue under some circumstances when job.cancel() was run o…
Browse files Browse the repository at this point in the history
…n a job with option `{ dependents: false }`.
  • Loading branch information
vsivsi committed Jun 26, 2017
1 parent cc835c5 commit 3ec32be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
## Revision history

#### V.NEXT

* Fixed an issue under some circumstances when `job.cancel()` was run on a job with option `{ dependents: false }`. Thanks @gbhrdt.

#### 1.5.1

* Fixed issue introduced in 1.5.0 which caused `processJobs()` with arrays of jobType strings to fail a new type check. Thanks @danielparas!
* Fixed issue introduced in 1.5.0 which caused `processJobs()` with arrays of jobType strings to fail a new type check. Thanks @danielparas.

#### 1.5.0

Expand Down
4 changes: 2 additions & 2 deletions src/shared.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class JobCollectionBase extends Mongo.Collection
# Dependents: jobs that list one of the ids in their depends list
# Antecedents: jobs with an id listed in the depends list of one of the jobs in ids
dependsQuery = []
dependsIds = []
if dependents
dependsQuery.push
depends:
Expand All @@ -254,8 +255,7 @@ class JobCollectionBase extends Mongo.Collection
dependsQuery.push
_id:
$in: antsArray
if dependsQuery
dependsIds = []
if dependsQuery.length > 0
@find(
{
status:
Expand Down
12 changes: 12 additions & 0 deletions test/job_collection_tests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,18 @@ Tinytest.addAsync 'Dependent job saved after removed antecedent is cancelled', (
test.isNull res, "job2.save() failed in callback result"
onComplete()

Tinytest.addAsync 'Cancel succeeds for job without deps, with using option dependents: false', (test, onComplete) ->
jobType = "TestJob_#{Math.round(Math.random()*1000000000)}"
job = new Job testColl, jobType, {}
job.save (err, res) ->
test.fail(err) if err
test.ok validId(res), "job.save() failed in callback result"
job.cancel { dependents: false }, (err, res) ->
console.error "Error?", err
test.fail(err) if err
test.ok res
onComplete()

Tinytest.addAsync 'Dependent job with delayDeps is delayed', (test, onComplete) ->
jobType = "TestJob_#{Math.round(Math.random()*1000000000)}"
job = new Job testColl, jobType, { order: 1 }
Expand Down

0 comments on commit 3ec32be

Please sign in to comment.