@abtnode/queue 1.16.17-beta-2ac96448 → 1.16.17-beta-3232a7af

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -120,6 +120,8 @@ module.exports = function createQueue({ file, store, onJob, options = {} }) {
120
120
 
121
121
  const id = getJobId(jobId, job);
122
122
 
123
+ logger.info('push', { job, jobId, persist, delay, id });
124
+
123
125
  if (delay) {
124
126
  if (!enableScheduledJob) {
125
127
  throw new Error('The queue must have options.enableScheduledJob set to true to run delay jobs');
@@ -148,14 +150,14 @@ module.exports = function createQueue({ file, store, onJob, options = {} }) {
148
150
 
149
151
  const onJobComplete = async (err, result) => {
150
152
  if (result === CANCELLED) {
153
+ await clearJob(id);
151
154
  emit('cancelled', { id, job, result });
152
- clearJob(id);
153
155
  return;
154
156
  }
155
157
 
156
158
  if (!err) {
159
+ await clearJob(id);
157
160
  emit('finished', { id, job, result });
158
- clearJob(id);
159
161
  return;
160
162
  }
161
163
 
@@ -266,8 +268,16 @@ module.exports = function createQueue({ file, store, onJob, options = {} }) {
266
268
  try {
267
269
  /* eslint-disable no-await-in-loop */
268
270
  const jobs = await store.getScheduledJobs();
271
+
272
+ logger.info('loop.$jobs', jobs);
273
+ logger.info(
274
+ 'loop.$job.ids',
275
+ jobs.map((x) => x.id)
276
+ );
277
+
269
278
  for (const x of jobs) {
270
279
  if (x.job && x.id) {
280
+ await cancel(x.id);
271
281
  push(x.job, x.id, false);
272
282
  } else {
273
283
  logger.info('skip invalid job from db', { job: x });
@@ -21,7 +21,7 @@ class SequelizeStore {
21
21
 
22
22
  getScheduledJobs() {
23
23
  return this.db.find(
24
- { queue: this.queue, delay: { $exists: true }, willRunAt: { $lte: Date.now() } },
24
+ { queue: this.queue, delay: { $exists: true }, willRunAt: { $lte: Date.now() }, cancelled: false },
25
25
  {},
26
26
  { createdAt: 1 }
27
27
  );
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.17-beta-2ac96448",
6
+ "version": "1.16.17-beta-3232a7af",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,13 +19,13 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/db": "1.16.17-beta-2ac96448",
23
- "@abtnode/util": "1.16.17-beta-2ac96448",
22
+ "@abtnode/db": "1.16.17-beta-3232a7af",
23
+ "@abtnode/util": "1.16.17-beta-3232a7af",
24
24
  "debug": "^4.3.4",
25
25
  "fastq": "^1.13.0",
26
26
  "uuid": "^8.3.2"
27
27
  },
28
- "gitHead": "3f18c2e1dd086879b22faf92b6b6954898ed72ef",
28
+ "gitHead": "af4067dd2e418c51a0ed96b1ee242ca812904056",
29
29
  "devDependencies": {
30
30
  "jest": "^27.5.1"
31
31
  }