@rvoh/psychic-workers 2.4.0 → 2.4.1

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.
@@ -62,9 +62,9 @@ export default class WorkerTestUtils {
62
62
  }
63
63
  /*
64
64
  * iterates through each registered queue, and cleans out all
65
- * jobs, including completed, failed, and scheduled jobs. This
66
- * is especially useful before a test where you plan to exercise
67
- * background jobs manually.
65
+ * jobs, including waiting, paused, prioritized, delayed, completed,
66
+ * failed, and scheduled jobs. This is especially useful before a test
67
+ * where you plan to exercise background jobs manually.
68
68
  *
69
69
  * If your entire app is continuously exercising background jobs
70
70
  * manually, you may want to do this in your spec/setup/hooks.ts file,
@@ -79,8 +79,11 @@ export default class WorkerTestUtils {
79
79
  static async clean() {
80
80
  background.connect();
81
81
  for (const queue of background.queues) {
82
- // clears all non-scheduled, non-completed, and non-failed jobs
83
- await queue.drain();
82
+ // clears waiting, paused, and prioritized jobs, as well as delayed jobs
83
+ // (i.e. jobs which have failed and are awaiting a retry). Delayed jobs which
84
+ // belong to a job scheduler are intentionally left alone by BullMQ here, and
85
+ // are cleaned up below when their scheduler is removed.
86
+ await queue.drain(true);
84
87
  // clear out completed and failed jobs
85
88
  await queue.clean(0, 10000, 'completed');
86
89
  await queue.clean(0, 10000, 'failed');
@@ -62,9 +62,9 @@ export default class WorkerTestUtils {
62
62
  }
63
63
  /*
64
64
  * iterates through each registered queue, and cleans out all
65
- * jobs, including completed, failed, and scheduled jobs. This
66
- * is especially useful before a test where you plan to exercise
67
- * background jobs manually.
65
+ * jobs, including waiting, paused, prioritized, delayed, completed,
66
+ * failed, and scheduled jobs. This is especially useful before a test
67
+ * where you plan to exercise background jobs manually.
68
68
  *
69
69
  * If your entire app is continuously exercising background jobs
70
70
  * manually, you may want to do this in your spec/setup/hooks.ts file,
@@ -79,8 +79,11 @@ export default class WorkerTestUtils {
79
79
  static async clean() {
80
80
  background.connect();
81
81
  for (const queue of background.queues) {
82
- // clears all non-scheduled, non-completed, and non-failed jobs
83
- await queue.drain();
82
+ // clears waiting, paused, and prioritized jobs, as well as delayed jobs
83
+ // (i.e. jobs which have failed and are awaiting a retry). Delayed jobs which
84
+ // belong to a job scheduler are intentionally left alone by BullMQ here, and
85
+ // are cleaned up below when their scheduler is removed.
86
+ await queue.drain(true);
84
87
  // clear out completed and failed jobs
85
88
  await queue.clean(0, 10000, 'completed');
86
89
  await queue.clean(0, 10000, 'failed');
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "name": "@rvoh/psychic-workers",
4
4
  "description": "Background job system for Psychic applications",
5
- "version": "2.4.0",
5
+ "version": "2.4.1",
6
6
  "author": "RVO Health",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -48,7 +48,7 @@
48
48
  "build:test-app": "rm -rf dist && echo \"building test app to esm...\" && tsc -p ./tsconfig.esm.build.test-app.json && echo \"building test app to cjs...\" && tsc -p ./tsconfig.cjs.build.test-app.json",
49
49
  "uspec": "vitest --config ./spec/unit/vite.config.ts",
50
50
  "format": "pnpm prettier . --write",
51
- "lint": "pnpm eslint --no-warn-ignored \"src/**/*.ts\" && pnpm prettier . --check",
51
+ "lint": "pnpm eslint --no-warn-ignored \"src/**/*.ts\" \"spec/**/*.ts\" \"test-app/**/*.ts\" && pnpm prettier . --check",
52
52
  "console": "tsx ./src/conf/repl.ts",
53
53
  "console:js": "node ./dist/src/conf/repl.js",
54
54
  "prepack": "pnpm build",