Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vendure/job-queue-plugin

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vendure/job-queue-plugin - npm Package Compare versions

Comparing version 2.0.0-next.28 to 2.0.0

64

package.json
{
"name": "@vendure/job-queue-plugin",
"version": "2.0.0-next.28",
"license": "MIT",
"main": "package/index.js",
"types": "package/index.d.ts",
"files": [
"package/**/*"
],
"private": false,
"scripts": {
"watch": "tsc -p ./tsconfig.build.json --watch",
"build": "rimraf package && tsc -p ./tsconfig.build.json",
"lint": "tslint --fix --project ./",
"test": "jest --config ./jest.config.js",
"e2e-wip": "node e2e/check-connection.js || jest --config ../../e2e-common/jest-config.js --runInBand --package=job-queue-plugin",
"ci": "yarn build"
},
"homepage": "https://www.vendure.io/",
"funding": "https://github.com/sponsors/michaelbromley",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@google-cloud/pubsub": "^2.8.0",
"@types/ioredis": "^4.28.10",
"@vendure/common": "^2.0.0-next.28",
"@vendure/core": "^2.0.0-next.28",
"bullmq": "^1.86.7",
"rimraf": "^3.0.2",
"typescript": "4.5.5"
},
"gitHead": "6811d6554afbb0e0d993da4788499bcd3563d5ab"
"name": "@vendure/job-queue-plugin",
"version": "2.0.0",
"license": "MIT",
"main": "package/index.js",
"types": "package/index.d.ts",
"files": [
"package/**/*"
],
"private": false,
"scripts": {
"watch": "tsc -p ./tsconfig.build.json --watch",
"build": "rimraf package && tsc -p ./tsconfig.build.json",
"lint": "eslint --fix .",
"test": "vitest --run",
"e2e-wip": "node e2e/check-connection.js || jest --config ../../e2e-common/jest-config.js --runInBand --package=job-queue-plugin",
"ci": "yarn build"
},
"homepage": "https://www.vendure.io/",
"funding": "https://github.com/sponsors/michaelbromley",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@google-cloud/pubsub": "^2.8.0",
"@vendure/common": "^2.0.0",
"@vendure/core": "^2.0.0",
"bullmq": "^3.6.1",
"ioredis": "^5.3.0",
"rimraf": "^3.0.2",
"typescript": "4.9.5"
},
"gitHead": "302bd68796e0136f70dd199369616d362c920ea4"
}

@@ -8,3 +8,3 @@ import { JobListOptions } from '@vendure/common/lib/generated-types';

*
* @docsCategory job-queue-plugin
* @docsCategory core plugins/JobQueuePlugin
*/

@@ -16,3 +16,2 @@ export declare class BullMQJobQueueStrategy implements InspectableJobQueueStrategy {

private worker;
private scheduler;
private workerProcessor;

@@ -23,3 +22,3 @@ private options;

destroy(): Promise<void>;
add<Data extends JobData<Data> = {}>(job: Job<Data>): Promise<Job<Data>>;
add<Data extends JobData<Data> = object>(job: Job<Data>): Promise<Job<Data>>;
cancelJob(jobId: string): Promise<Job | undefined>;

@@ -30,7 +29,7 @@ findMany(options?: JobListOptions): Promise<PaginatedList<Job>>;

removeSettledJobs(queueNames?: string[], olderThan?: Date): Promise<number>;
start<Data extends JobData<Data> = {}>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
start<Data extends JobData<Data> = object>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
private stopped;
stop<Data extends JobData<Data> = {}>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
stop<Data extends JobData<Data> = object>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
private createVendureJob;
private getState;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -12,3 +9,3 @@ exports.BullMQJobQueueStrategy = void 0;

const events_1 = require("events");
const ioredis_1 = __importDefault(require("ioredis"));
const ioredis_1 = require("ioredis");
const constants_1 = require("./constants");

@@ -23,3 +20,3 @@ const redis_health_indicator_1 = require("./redis-health-indicator");

*
* @docsCategory job-queue-plugin
* @docsCategory core plugins/JobQueuePlugin
*/

@@ -44,5 +41,5 @@ class BullMQJobQueueStrategy {

? this.connectionOptions
: new ioredis_1.default(this.connectionOptions);
: new ioredis_1.Redis(this.connectionOptions);
const redisHealthIndicator = injector.get(redis_health_indicator_1.RedisHealthIndicator);
core_1.Logger.info(`Checking Redis connection...`, constants_1.loggerCtx);
core_1.Logger.info('Checking Redis connection...', constants_1.loggerCtx);
const health = await redisHealthIndicator.isHealthy('redis');

@@ -53,8 +50,8 @@ if (health.redis.status === 'down') {

else {
core_1.Logger.info(`Connected to Redis ✔`, constants_1.loggerCtx);
core_1.Logger.info('Connected to Redis ✔', constants_1.loggerCtx);
}
this.queue = new bullmq_1.Queue(QUEUE_NAME, Object.assign(Object.assign({}, options.queueOptions), { connection: this.redisConnection }))
.on('error', (e) => core_1.Logger.error(`BullMQ Queue error: ${e.message}`, constants_1.loggerCtx, e.stack))
.on('resumed', () => core_1.Logger.verbose(`BullMQ Queue resumed`, constants_1.loggerCtx))
.on('paused', () => core_1.Logger.verbose(`BullMQ Queue paused`, constants_1.loggerCtx));
.on('error', (e) => core_1.Logger.error(`BullMQ Queue error: ${JSON.stringify(e.message)}`, constants_1.loggerCtx, e.stack))
.on('resumed', () => core_1.Logger.verbose('BullMQ Queue resumed', constants_1.loggerCtx))
.on('paused', () => core_1.Logger.verbose('BullMQ Queue paused', constants_1.loggerCtx));
if (await this.queue.isPaused()) {

@@ -64,5 +61,5 @@ await this.queue.resume();

this.workerProcessor = async (bullJob) => {
var _a;
var _a, _b;
const queueName = bullJob.name;
core_1.Logger.debug(`Job ${bullJob.id} [${queueName}] starting (attempt ${bullJob.attemptsMade + 1} of ${(_a = bullJob.opts.attempts) !== null && _a !== void 0 ? _a : 1})`);
core_1.Logger.debug(`Job ${(_a = bullJob.id) !== null && _a !== void 0 ? _a : ''} [${queueName}] starting (attempt ${bullJob.attemptsMade + 1} of ${(_b = bullJob.opts.attempts) !== null && _b !== void 0 ? _b : 1})`);
const processFn = this.queueNameProcessFnMap.get(queueName);

@@ -72,2 +69,3 @@ if (processFn) {

try {
// eslint-disable-next-line
job.on('progress', _job => bullJob.updateProgress(_job.progress));

@@ -84,10 +82,6 @@ const result = await processFn(job);

};
this.scheduler = new bullmq_1.QueueScheduler(QUEUE_NAME, Object.assign(Object.assign({}, options.schedulerOptions), { connection: this.redisConnection }))
.on('error', (e) => core_1.Logger.error(`BullMQ Scheduler error: ${e.message}`, constants_1.loggerCtx, e.stack))
.on('stalled', jobId => core_1.Logger.warn(`BullMQ Scheduler stalled on job ${jobId}`, constants_1.loggerCtx))
.on('failed', jobId => core_1.Logger.warn(`BullMQ Scheduler failed on job ${jobId}`, constants_1.loggerCtx));
}
async destroy() {
var _a;
await Promise.all([this.queue.close(), (_a = this.worker) === null || _a === void 0 ? void 0 : _a.close(), this.scheduler.close()]);
await Promise.all([this.queue.close(), (_a = this.worker) === null || _a === void 0 ? void 0 : _a.close()]);
}

@@ -113,3 +107,3 @@ async add(job) {

// https://github.com/taskforcesh/bullmq/issues/632
throw new core_1.InternalServerError(`Cannot cancel a running job`);
throw new core_1.InternalServerError('Cannot cancel a running job');
}

@@ -121,3 +115,3 @@ try {

catch (e) {
const message = `Error when cancelling job: ${e.message}`;
const message = `Error when cancelling job: ${JSON.stringify(e.message)}`;
core_1.Logger.error(message, constants_1.loggerCtx);

@@ -195,2 +189,3 @@ throw new core_1.InternalServerError(message);

}
// TODO V2: actually make it use the olderThan parameter
async removeSettledJobs(queueNames, olderThan) {

@@ -208,2 +203,3 @@ try {

}
// eslint-disable-next-line @typescript-eslint/require-await
async start(queueName, process) {

@@ -216,9 +212,13 @@ this.queueNameProcessFnMap.set(queueName, process);

.on('closing', e => core_1.Logger.verbose(`BullMQ Worker closing: ${e}`, constants_1.loggerCtx))
.on('closed', () => core_1.Logger.verbose(`BullMQ Worker closed`))
.on('failed', (job, failedReason) => {
.on('closed', () => core_1.Logger.verbose('BullMQ Worker closed'))
.on('failed', (job, error) => {
var _a, _b, _c, _d;
core_1.Logger.warn(`Job ${(_a = job === null || job === void 0 ? void 0 : job.id) !== null && _a !== void 0 ? _a : '(unknown id)'} [${(_b = job === null || job === void 0 ? void 0 : job.name) !== null && _b !== void 0 ? _b : 'unknown name'}] failed (attempt ${(_c = job === null || job === void 0 ? void 0 : job.attemptsMade) !== null && _c !== void 0 ? _c : 'unknown'} of ${(_d = job === null || job === void 0 ? void 0 : job.opts.attempts) !== null && _d !== void 0 ? _d : 1})`);
})
.on('stalled', (jobId) => {
core_1.Logger.warn(`BullMQ Worker: job ${jobId} stalled`, constants_1.loggerCtx);
})
.on('completed', (job) => {
var _a;
core_1.Logger.warn(`Job ${job.id} [${job.name}] failed (attempt ${job.attemptsMade} of ${(_a = job.opts.attempts) !== null && _a !== void 0 ? _a : 1})`);
})
.on('completed', (job, failedReason) => {
core_1.Logger.debug(`Job ${job.id} [${job.name}] completed`);
core_1.Logger.debug(`Job ${(_a = job === null || job === void 0 ? void 0 : job.id) !== null && _a !== void 0 ? _a : 'unknown id'} [${job.name}] completed`);
});

@@ -231,7 +231,3 @@ }

try {
await Promise.all([
this.scheduler.disconnect(),
this.queue.disconnect(),
this.worker.disconnect(),
]);
await Promise.all([this.queue.disconnect(), this.worker.disconnect()]);
}

@@ -238,0 +234,0 @@ catch (e) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -15,7 +19,7 @@ if (k2 === undefined) k2 = k;

try {
// tslint:disable-next-line:no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('bullmq');
}
catch (e) {
// tslint:disable-next-line:no-console
// eslint-disable-next-line no-console
console.error('The BullMQJobQueuePlugin depends on the "bullmq" package being installed.');

@@ -22,0 +26,0 @@ process.exit(1);

@@ -92,3 +92,3 @@ import { BullMQPluginOptions } from './types';

*
* @docsCategory job-queue-plugin
* @docsCategory core plugins/JobQueuePlugin
*/

@@ -95,0 +95,0 @@ export declare class BullMQJobQueuePlugin {

@@ -107,3 +107,3 @@ "use strict";

*
* @docsCategory job-queue-plugin
* @docsCategory core plugins/JobQueuePlugin
*/

@@ -133,2 +133,3 @@ let BullMQJobQueuePlugin = BullMQJobQueuePlugin_1 = class BullMQJobQueuePlugin {

],
compatibility: '^2.0.0',
})

@@ -135,0 +136,0 @@ ], BullMQJobQueuePlugin);

@@ -31,3 +31,3 @@ "use strict";

connection.on('error', err => {
core_1.Logger.error(`Redis health check error: ${err.message}`, constants_1.loggerCtx, err.stack);
core_1.Logger.error(`Redis health check error: ${JSON.stringify(err.message)}`, constants_1.loggerCtx, err.stack);
resolve(err);

@@ -45,3 +45,3 @@ });

}
client.ping((err, res) => {
void client.ping((err, res) => {
if (err) {

@@ -64,3 +64,3 @@ resolve(err);

catch (e) {
core_1.Logger.error(`Redis health check error closing connection: ${e.message}`, constants_1.loggerCtx, e.stack);
core_1.Logger.error(`Redis health check error closing connection: ${JSON.stringify(e.message)}`, constants_1.loggerCtx, e.stack);
}

@@ -67,0 +67,0 @@ const result = this.getStatus(key, pingResult === 'PONG');

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisJobBufferStorageStrategy = void 0;
const core_1 = require("@vendure/core");
const ioredis_1 = __importStar(require("ioredis"));
const ioredis_1 = require("ioredis");
const constants_1 = require("./constants");

@@ -30,3 +11,3 @@ const BUFFER_LIST_PREFIX = 'vendure-job-buffer';

const options = injector.get(constants_1.BULLMQ_PLUGIN_OPTIONS);
if (options.connection instanceof ioredis_1.default) {
if (options.connection instanceof ioredis_1.Redis) {
this.redis = options.connection;

@@ -38,3 +19,3 @@ }

else {
this.redis = new ioredis_1.default(options.connection);
this.redis = new ioredis_1.Redis(options.connection);
}

@@ -81,3 +62,3 @@ }

catch (e) {
core_1.Logger.error(`Could not parse buffered job:\n${e.message}`, constants_1.loggerCtx, e.stack);
core_1.Logger.error(`Could not parse buffered job:\n${JSON.stringify(e.message)}`, constants_1.loggerCtx, e.stack);
throw e;

@@ -87,5 +68,9 @@ }

async getAllBufferIds() {
const stream = this.redis.scanStream({
match: `${BUFFER_LIST_PREFIX}:*`,
});
const stream = this.redis instanceof ioredis_1.Redis
? this.redis.scanStream({
match: `${BUFFER_LIST_PREFIX}:*`,
})
: this.redis.nodes()[0].scanStream({
match: `${BUFFER_LIST_PREFIX}:*`,
});
const keys = await new Promise((resolve, reject) => {

@@ -92,0 +77,0 @@ const allKeys = [];

import { Job } from '@vendure/core';
import { ConnectionOptions, QueueSchedulerOptions, WorkerOptions } from 'bullmq';
import { ConnectionOptions, WorkerOptions } from 'bullmq';
import { QueueOptions } from 'bullmq';

@@ -9,3 +9,3 @@ /**

* @since 1.2.0
* @docsCategory job-queue-plugin
* @docsCategory core plugins/JobQueuePlugin
* @docsPage BullMQPluginOptions

@@ -39,9 +39,2 @@ * @docsWeight 0

* @description
* Additional options used when instantiating the BullMQ
* QueueScheduler instance.
* See the [BullMQ QueueSchedulerOptions docs](https://github.com/taskforcesh/bullmq/blob/master/docs/gitbook/api/bullmq.queuescheduleroptions.md)
*/
schedulerOptions?: Exclude<QueueSchedulerOptions, 'connection'>;
/**
* @description
* When a job is added to the JobQueue using `JobQueue.add()`, the calling

@@ -94,3 +87,3 @@ * code may specify the number of retries in case of failure. This option allows

* @since 1.3.0
* @docsCategory job-queue-plugin
* @docsCategory core plugins/JobQueuePlugin
* @docsPage BullMQPluginOptions

@@ -97,0 +90,0 @@ * @docsWeight 1

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -32,2 +32,3 @@ "use strict";

},
compatibility: '^2.0.0',
})

@@ -34,0 +35,0 @@ ], PubSubPlugin);

@@ -11,7 +11,7 @@ import { InjectableJobQueueStrategy, Injector, Job, JobData, JobQueueStrategy } from '@vendure/core';

destroy(): void;
add<Data extends JobData<Data> = {}>(job: Job<Data>): Promise<Job<Data>>;
start<Data extends JobData<Data> = {}>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
stop<Data extends JobData<Data> = {}>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
add<Data extends JobData<Data> = object>(job: Job<Data>): Promise<Job<Data>>;
start<Data extends JobData<Data> = object>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
stop<Data extends JobData<Data> = object>(queueName: string, process: (job: Job<Data>) => Promise<any>): Promise<void>;
private topic;
private subscription;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc