@imqueue/job 2.0.1 → 2.0.3
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/debug.d.ts +1 -0
- package/index.js +7 -4
- package/package.json +8 -8
package/debug.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.js
CHANGED
|
@@ -114,7 +114,7 @@ class JobQueuePublisher extends BaseJobQueue {
|
|
|
114
114
|
*/
|
|
115
115
|
push(job, options) {
|
|
116
116
|
options = options || {};
|
|
117
|
-
this.imq.send(this.name, Object.assign(Object.assign({ job: job }, (options.ttl ? { expire: Date.now() + options.ttl } : {})), (options.delay ? { delay: options.delay } : {})), options.delay).catch(err => this.logger.log('JobQueue push error:', err));
|
|
117
|
+
this.imq.send(this.name, Object.assign(Object.assign({ job: job }, (options.ttl ? { expire: Date.now() + options.ttl } : {})), (options.delay ? { delay: options.delay } : {})), options.delay).catch(err => this.logger.log('[JobQueue] push error:', err));
|
|
118
118
|
return this;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -146,6 +146,9 @@ class JobQueueWorker extends BaseJobQueue {
|
|
|
146
146
|
this.handler = handler;
|
|
147
147
|
this.imq.removeAllListeners('message');
|
|
148
148
|
this.imq.on('message', async (message) => {
|
|
149
|
+
if (typeof message !== 'object' || !message) {
|
|
150
|
+
this.logger.warn('[JobQueue] Invalid message received:', JSON.stringify(message));
|
|
151
|
+
}
|
|
149
152
|
const { job, expire, delay } = message;
|
|
150
153
|
let rescheduleDelay;
|
|
151
154
|
try {
|
|
@@ -160,7 +163,7 @@ class JobQueueWorker extends BaseJobQueue {
|
|
|
160
163
|
}
|
|
161
164
|
catch (err) {
|
|
162
165
|
rescheduleDelay = delay;
|
|
163
|
-
this.logger.log('Error handling job:', err);
|
|
166
|
+
this.logger.log('[JobQueue] Error handling job:', err);
|
|
164
167
|
}
|
|
165
168
|
if (typeof expire === 'number' && expire <= Date.now()) {
|
|
166
169
|
return; // remove job from queue
|
|
@@ -200,7 +203,7 @@ class JobQueue extends BaseJobQueue {
|
|
|
200
203
|
*/
|
|
201
204
|
async start() {
|
|
202
205
|
if (!this.handler) {
|
|
203
|
-
throw new TypeError('Message handler is not set, can not start job queue!');
|
|
206
|
+
throw new TypeError('[JobQueue] Message handler is not set, can not start job queue!');
|
|
204
207
|
}
|
|
205
208
|
return await super.start();
|
|
206
209
|
}
|
|
@@ -214,7 +217,7 @@ class JobQueue extends BaseJobQueue {
|
|
|
214
217
|
*/
|
|
215
218
|
push(job, options) {
|
|
216
219
|
if (!this.handler) {
|
|
217
|
-
throw new TypeError('Message handler is not set, can not enqueue data!');
|
|
220
|
+
throw new TypeError('[JobQueue] Message handler is not set, can not enqueue data!');
|
|
218
221
|
}
|
|
219
222
|
return JobQueuePublisher.prototype.push.call(this, job, options);
|
|
220
223
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/job",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Simple job queue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"message-queue",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
|
|
37
37
|
"license": "GPL-3.0-only",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@imqueue/core": "^2.0.
|
|
39
|
+
"@imqueue/core": "^2.0.13"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/eslintrc": "^3.3.1",
|
|
43
|
-
"@eslint/js": "^9.
|
|
43
|
+
"@eslint/js": "^9.35.0",
|
|
44
44
|
"@types/chai": "^5.2.2",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|
|
46
46
|
"@types/mock-require": "^3.0.0",
|
|
47
47
|
"@types/node": "^24.3.1",
|
|
48
48
|
"@types/sinon": "^17.0.4",
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
50
|
-
"@typescript-eslint/parser": "^8.
|
|
51
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
50
|
+
"@typescript-eslint/parser": "^8.43.0",
|
|
51
|
+
"@typescript-eslint/typescript-estree": "^8.43.0",
|
|
52
52
|
"chai": "^6.0.1",
|
|
53
|
-
"eslint": "^9.
|
|
54
|
-
"globals": "^16.
|
|
53
|
+
"eslint": "^9.35.0",
|
|
54
|
+
"globals": "^16.4.0",
|
|
55
55
|
"mocha": "^11.7.2",
|
|
56
56
|
"mocha-lcov-reporter": "^1.3.0",
|
|
57
57
|
"mock-require": "^3.0.3",
|