Socket
Socket
Sign inDemoInstall

bullmq

Package Overview
Dependencies
Maintainers
1
Versions
531
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bullmq - npm Package Compare versions

Comparing version 1.6.4 to 1.6.5

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [1.6.5](https://github.com/taskforcesh/bullmq/compare/v1.6.4...v1.6.5) (2020-01-05)
### Bug Fixes
* get rid of flushdb/flushall in tests ([550c67b](https://github.com/taskforcesh/bullmq/commit/550c67b25de5f6d800e5e317398044cd16b85924))
## [1.6.4](https://github.com/taskforcesh/bullmq/compare/v1.6.3...v1.6.4) (2020-01-05)

@@ -2,0 +9,0 @@

3

dist/classes/compat.js

@@ -44,2 +44,5 @@ "use strict";

await this.queue.client;
if (this.queueEvents) {
await this.queueEvents.client;
}
return this;

@@ -46,0 +49,0 @@ }

1

dist/classes/queue-events.d.ts
import { QueueEventsOptions } from '../interfaces';
import { QueueBase } from './queue-base';
export declare class QueueEvents extends QueueBase {
consuming: Promise<void>;
constructor(name: string, opts?: QueueEventsOptions);

@@ -6,0 +5,0 @@ private consumeEvents;

@@ -11,4 +11,3 @@ "use strict";

}, this.opts);
// tslint:disable: no-floating-promises
this.consumeEvents().catch(err => this.emit('error'));
this.consumeEvents().catch(err => this.emit('error', err));
}

@@ -15,0 +14,0 @@ async consumeEvents() {

@@ -9,10 +9,6 @@ "use strict";

const uuid_1 = require("uuid");
const utils_1 = require("../utils");
mocha_1.describe('bulk jobs', () => {
let queue;
let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -24,3 +20,3 @@ queueName = 'test-' + uuid_1.v4();

await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -27,0 +23,0 @@ mocha_1.it('should process jobs', async () => {

@@ -15,7 +15,2 @@ "use strict";

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -25,3 +20,3 @@ queueName = 'test-' + uuid_1.v4();

queueEvents = new classes_1.QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -31,3 +26,3 @@ afterEach(async function () {

await queueEvents.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -34,0 +29,0 @@ mocha_1.it('should clean an empty queue', async () => {

@@ -19,7 +19,2 @@ /*eslint-env node */

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -31,3 +26,3 @@ queueName = 'test-' + uuid_1.v4();

await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -245,7 +240,2 @@ mocha_1.it('should get waiting jobs', async function () {

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -257,3 +247,3 @@ queueName = 'test-' + uuid_1.v4();

await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -308,3 +298,3 @@ mocha_1.it('should emit waiting when a job has been added', function (done) {

queue.once('global:completed', () => events.push('completed'));
await queue.queueEvents.waitUntilReady();
await queue.isReady();
await queue.add('test', {});

@@ -321,3 +311,4 @@ await queue.add('test', {});

queue.on('global:completed', () => events.push('completed'));
await queue.queueEvents.waitUntilReady();
await queue.isReady();
await utils_1.delay(50); // additional delay since XREAD from '$' is unstable
await queue.add('test', {});

@@ -340,7 +331,2 @@ await queue.add('test', {});

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -352,3 +338,3 @@ queueName = 'test-' + uuid_1.v4();

await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -355,0 +341,0 @@ // it('should pause a queue until resumed', async () => {

@@ -8,19 +8,13 @@ "use strict";

const chai_1 = require("chai");
const utils_1 = require("@src/utils");
describe('connection', () => {
let queue;
let queueName;
let client;
beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
beforeEach(function () {
beforeEach(async function () {
queueName = 'test-' + uuid_1.v4();
queue = new classes_1.Queue(queueName, {
connection: { port: 6379, host: '127.0.0.1' },
});
queue = new classes_1.Queue(queueName);
});
afterEach(async () => {
await client.quit();
await queue.close();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -27,0 +21,0 @@ it('should recover from a connection loss', async () => {

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

const queue_scheduler_1 = require("@src/classes/queue-scheduler");
const utils_1 = require("@src/utils");
mocha_1.describe('Delayed jobs', function () {

@@ -17,7 +18,2 @@ this.timeout(15000);

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -29,3 +25,3 @@ queueName = 'test-' + uuid_1.v4();

await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -32,0 +28,0 @@ mocha_1.it('should process a delayed job only after delayed time', async function () {

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

const uuid_1 = require("uuid");
const utils_1 = require("@src/utils");
mocha_1.describe('events', function () {

@@ -17,7 +18,2 @@ this.timeout(4000);

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -27,3 +23,3 @@ queueName = 'test-' + uuid_1.v4();

queueEvents = new queue_events_1.QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -33,3 +29,3 @@ afterEach(async function () {

await queueEvents.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -94,2 +90,3 @@ mocha_1.it('should emit waiting when a job has been added', async function () {

let state;
await utils_1.delay(50); // additional delay since XREAD from '$' is unstable
queueEvents.on('waiting', function () {

@@ -114,4 +111,5 @@ chai_1.expect(state).to.be.undefined;

mocha_1.it('should trim events automatically', async () => {
const worker = new worker_1.Worker('test', async () => { });
const trimmedQueue = new classes_1.Queue('test', {
const queueName = 'test-' + uuid_1.v4();
const worker = new worker_1.Worker(queueName, async () => { });
const trimmedQueue = new classes_1.Queue(queueName, {
streams: {

@@ -138,5 +136,7 @@ events: {

await trimmedQueue.close();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});
mocha_1.it('should trim events manually', async () => {
const trimmedQueue = new classes_1.Queue('test-manual');
const queueName = 'test-manual-' + uuid_1.v4();
const trimmedQueue = new classes_1.Queue(queueName);
await trimmedQueue.add('test', {});

@@ -153,4 +153,5 @@ await trimmedQueue.add('test', {});

await trimmedQueue.close();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});
});
//# sourceMappingURL=test_events.js.map

@@ -13,2 +13,3 @@ /*eslint-env node */

const lodash_1 = require("lodash");
const utils_1 = require("@src/utils");
mocha_1.describe('Jobs getters', function () {

@@ -18,16 +19,9 @@ this.timeout(4000);

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {
queueName = 'test-' + uuid_1.v4();
queue = new classes_1.Queue(queueName, {
connection: { port: 6379, host: '127.0.0.1' },
});
queue = new classes_1.Queue(queueName);
});
afterEach(async function () {
await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -34,0 +28,0 @@ mocha_1.it('should get waiting jobs', async function () {

@@ -17,16 +17,9 @@ /*eslint-env node */

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(function () {
mocha_1.beforeEach(async function () {
queueName = 'test-' + uuid_1.v4();
queue = new classes_1.Queue(queueName, {
connection: { port: 6379, host: '127.0.0.1' },
});
queue = new classes_1.Queue(queueName);
});
mocha_1.afterEach(async () => {
await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -378,3 +371,3 @@ mocha_1.describe('.create', function () {

queueEvents = new queue_events_1.QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -381,0 +374,0 @@ mocha_1.afterEach(async function () {

@@ -16,7 +16,2 @@ "use strict";

let queueEvents;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -31,3 +26,3 @@ queueName = 'test-' + uuid_1.v4();

await queueEvents.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -34,0 +29,0 @@ // Skipped since some side effect makes this test fail

@@ -17,7 +17,5 @@ "use strict";

let queueEvents: QueueEvents;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});

@@ -35,3 +33,3 @@

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -38,0 +36,0 @@

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

const uuid_1 = require("uuid");
const utils_1 = require("@src/utils");
mocha_1.describe('Rate Limiter', function () {

@@ -18,7 +19,2 @@ let queue;

let queueEvents;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -33,3 +29,3 @@ queueName = 'test-' + uuid_1.v4();

await queueEvents.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -36,0 +32,0 @@ mocha_1.it('should put a job into the delayed queue when limit is hit', async () => {

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

const lodash_1 = require("lodash");
const utils_1 = require("@src/utils");
const sinon = require('sinon');

@@ -29,7 +30,4 @@ const moment = require('moment');

let queueName;
let client;
mocha_1.beforeEach(function () {
this.clock = sinon.useFakeTimers();
client = new ioredis_1.default();
return client.flushdb();
});

@@ -41,3 +39,3 @@ mocha_1.beforeEach(async function () {

queueEvents = new queue_events_1.QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -49,3 +47,3 @@ afterEach(async function () {

await queueEvents.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -52,0 +50,0 @@ mocha_1.it('should create multiple jobs if they have the same cron pattern', async function () {

@@ -16,12 +16,7 @@ "use strict";

let queueName;
let client;
mocha_1.beforeEach(() => {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async () => {
mocha_1.beforeEach(async function () {
queueName = 'test-' + uuid_1.v4();
queue = new classes_1.Queue(queueName);
queueEvents = new classes_1.QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -31,5 +26,4 @@ afterEach(async () => {

await queueEvents.close();
await client.flushall();
classes_1.pool.clean();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -36,0 +30,0 @@ it('should process and complete', async () => {

@@ -14,7 +14,2 @@ "use strict";

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -26,3 +21,3 @@ queueName = 'test-' + uuid_1.v4();

await queue.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -29,0 +24,0 @@ mocha_1.it('process stalled jobs when starting a queue', async function () {

@@ -18,7 +18,2 @@ "use strict";

let queueName;
let client;
mocha_1.beforeEach(function () {
client = new ioredis_1.default();
return client.flushdb();
});
mocha_1.beforeEach(async function () {

@@ -28,3 +23,3 @@ queueName = 'test-' + uuid_1.v4();

queueEvents = new classes_1.QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -35,3 +30,3 @@ afterEach(async function () {

await queueEvents.close();
return client.quit();
await utils_1.removeAllQueueData(new ioredis_1.default(), queueName);
});

@@ -38,0 +33,0 @@ mocha_1.it('should get all workers for this queue', async function () {

@@ -0,1 +1,2 @@

import IORedis from 'ioredis';
export declare const errorObject: {

@@ -11,1 +12,2 @@ [index: string]: any;

export declare function isRedisInstance(obj: any): boolean;
export declare function removeAllQueueData(client: IORedis.Redis, queueName: string, prefix?: string): Promise<unknown>;

@@ -1,2 +0,2 @@

'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -45,2 +45,28 @@ exports.errorObject = { value: null };

exports.isRedisInstance = isRedisInstance;
async function removeAllQueueData(client, queueName, prefix = 'bull') {
const pattern = `${prefix}:${queueName}:*`;
return new Promise((resolve, reject) => {
const stream = client.scanStream({
match: pattern,
});
stream.on('data', (keys) => {
if (keys.length) {
const pipeline = client.pipeline();
keys.forEach(key => {
pipeline.del(key);
});
pipeline.exec().catch(error => {
reject(error);
});
}
});
stream.on('end', () => {
resolve();
});
stream.on('error', error => {
reject(error);
});
});
}
exports.removeAllQueueData = removeAllQueueData;
//# sourceMappingURL=utils.js.map
{
"name": "bullmq",
"version": "1.6.4",
"version": "1.6.5",
"description": "Queue for messages and jobs based on Redis",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -73,2 +73,5 @@ // Type definitions for bull 3.10

await this.queue.client;
if (this.queueEvents) {
await this.queueEvents.client;
}
return this;

@@ -75,0 +78,0 @@ }

@@ -6,4 +6,2 @@ import { QueueEventsOptions } from '../interfaces';

export class QueueEvents extends QueueBase {
consuming: Promise<void>;
constructor(name: string, opts?: QueueEventsOptions) {

@@ -19,4 +17,3 @@ super(name, opts);

// tslint:disable: no-floating-promises
this.consumeEvents().catch(err => this.emit('error'));
this.consumeEvents().catch(err => this.emit('error', err));
}

@@ -23,0 +20,0 @@

@@ -6,2 +6,3 @@ import { Queue, Worker, Job } from '../classes';

import { v4 } from 'uuid';
import { removeAllQueueData } from '../utils';

@@ -11,9 +12,3 @@ describe('bulk jobs', () => {

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -26,3 +21,3 @@ queueName = 'test-' + v4();

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -29,0 +24,0 @@

import { Queue, QueueEvents, Worker } from '../classes';
import { delay } from '@src/utils';
import { delay, removeAllQueueData } from '@src/utils';
import { expect } from 'chai';

@@ -13,9 +13,3 @@ import IORedis from 'ioredis';

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -25,3 +19,3 @@ queueName = 'test-' + v4();

queueEvents = new QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -32,3 +26,3 @@

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -35,0 +29,0 @@

@@ -7,3 +7,3 @@ /*eslint-env node */

import { Queue3 } from '@src/classes/compat';
import { delay } from '@src/utils';
import { delay, removeAllQueueData } from '@src/utils';
import { expect } from 'chai';

@@ -20,9 +20,3 @@ import IORedis from 'ioredis';

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -35,3 +29,3 @@ queueName = 'test-' + v4();

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -298,9 +292,3 @@

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -313,3 +301,3 @@ queueName = 'test-' + v4();

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -382,3 +370,3 @@

queue.once('global:completed', () => events.push('completed'));
await queue.queueEvents.waitUntilReady();
await queue.isReady();
await queue.add('test', {});

@@ -396,3 +384,4 @@ await queue.add('test', {});

queue.on('global:completed', () => events.push('completed'));
await queue.queueEvents.waitUntilReady();
await queue.isReady();
await delay(50); // additional delay since XREAD from '$' is unstable
await queue.add('test', {});

@@ -416,9 +405,3 @@ await queue.add('test', {});

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -431,3 +414,3 @@ queueName = 'test-' + v4();

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -434,0 +417,0 @@

@@ -6,2 +6,3 @@ import IORedis from 'ioredis';

import { expect } from 'chai';
import { removeAllQueueData } from '@src/utils';

@@ -11,19 +12,11 @@ describe('connection', () => {

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(function() {
beforeEach(async function() {
queueName = 'test-' + v4();
queue = new Queue(queueName, {
connection: { port: 6379, host: '127.0.0.1' },
});
queue = new Queue(queueName);
});
afterEach(async () => {
await client.quit();
await queue.close();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -30,0 +23,0 @@

@@ -9,2 +9,3 @@ import { Queue, Job } from '@src/classes';

import { QueueScheduler } from '@src/classes/queue-scheduler';
import { removeAllQueueData } from '@src/utils';

@@ -16,9 +17,3 @@ describe('Delayed jobs', function() {

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -31,3 +26,3 @@ queueName = 'test-' + v4();

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -34,0 +29,0 @@

@@ -8,2 +8,3 @@ import { Queue } from '@src/classes';

import { v4 } from 'uuid';
import { delay, removeAllQueueData } from '@src/utils';

@@ -15,9 +16,3 @@ describe('events', function() {

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -27,3 +22,3 @@ queueName = 'test-' + v4();

queueEvents = new QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -34,3 +29,3 @@

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -119,2 +114,3 @@

let state: string;
await delay(50); // additional delay since XREAD from '$' is unstable
queueEvents.on('waiting', function() {

@@ -143,4 +139,6 @@ expect(state).to.be.undefined;

it('should trim events automatically', async () => {
const worker = new Worker('test', async () => {});
const trimmedQueue = new Queue('test', {
const queueName = 'test-' + v4();
const worker = new Worker(queueName, async () => {});
const trimmedQueue = new Queue(queueName, {
streams: {

@@ -180,6 +178,8 @@ events: {

await trimmedQueue.close();
await removeAllQueueData(new IORedis(), queueName);
});
it('should trim events manually', async () => {
const trimmedQueue = new Queue('test-manual');
const queueName = 'test-manual-' + v4();
const trimmedQueue = new Queue(queueName);

@@ -204,3 +204,4 @@ await trimmedQueue.add('test', {});

await trimmedQueue.close();
await removeAllQueueData(new IORedis(), queueName);
});
});

@@ -12,2 +12,3 @@ /*eslint-env node */

import { after } from 'lodash';
import { removeAllQueueData } from '@src/utils';

@@ -18,14 +19,6 @@ describe('Jobs getters', function() {

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {
queueName = 'test-' + v4();
queue = new Queue(queueName, {
connection: { port: 6379, host: '127.0.0.1' },
});
queue = new Queue(queueName);
});

@@ -35,3 +28,3 @@

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -38,0 +31,0 @@

@@ -8,3 +8,3 @@ /*eslint-env node */

import { JobsOptions } from '@src/interfaces';
import { delay } from '@src/utils';
import { delay, removeAllQueueData } from '@src/utils';
import { expect } from 'chai';

@@ -19,14 +19,6 @@ import IORedis from 'ioredis';

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(function() {
beforeEach(async function() {
queueName = 'test-' + v4();
queue = new Queue(queueName, {
connection: { port: 6379, host: '127.0.0.1' },
});
queue = new Queue(queueName);
});

@@ -36,3 +28,3 @@

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -463,3 +455,3 @@

queueEvents = new QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -466,0 +458,0 @@

@@ -8,3 +8,3 @@ import { Job, Queue } from '@src/classes';

import { v4 } from 'uuid';
import { delay } from '@src/utils';
import { delay, removeAllQueueData } from '@src/utils';

@@ -15,9 +15,3 @@ describe('Pause', function() {

let queueEvents: QueueEvents;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -33,3 +27,3 @@ queueName = 'test-' + v4();

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -36,0 +30,0 @@

@@ -16,7 +16,5 @@ /*

let queueEvents: QueueEvents;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});

@@ -34,3 +32,3 @@

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -37,0 +35,0 @@

@@ -10,2 +10,3 @@ import { Queue } from '@src/classes';

import { v4 } from 'uuid';
import { removeAllQueueData } from '@src/utils';

@@ -16,9 +17,3 @@ describe('Rate Limiter', function() {

let queueEvents: QueueEvents;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -34,3 +29,3 @@ queueName = 'test-' + v4();

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -37,0 +32,0 @@

@@ -11,2 +11,3 @@ import { Job, Queue } from '@src/classes';

import { defaults } from 'lodash';
import { removeAllQueueData } from '@src/utils';

@@ -30,8 +31,5 @@ const sinon = require('sinon');

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
this.clock = sinon.useFakeTimers();
client = new IORedis();
return client.flushdb();
});

@@ -44,3 +42,3 @@

queueEvents = new QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -53,3 +51,3 @@

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -56,0 +54,0 @@

@@ -7,3 +7,3 @@ import { expect } from 'chai';

import { v4 } from 'uuid';
import { delay } from '@src/utils';
import { delay, removeAllQueueData } from '@src/utils';
const pReflect = require('p-reflect');

@@ -15,14 +15,8 @@

let queueName: string;
let client: IORedis.Redis;
beforeEach(() => {
client = new IORedis();
return client.flushdb();
});
beforeEach(async () => {
beforeEach(async function() {
queueName = 'test-' + v4();
queue = new Queue(queueName);
queueEvents = new QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -33,5 +27,4 @@

await queueEvents.close();
await client.flushall();
pool.clean();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -38,0 +31,0 @@

import { Queue, QueueScheduler, Worker, QueueEvents } from '@src/classes';
import { delay } from '@src/utils';
import { delay, removeAllQueueData } from '@src/utils';
import IORedis from 'ioredis';

@@ -12,9 +12,3 @@ import { after } from 'lodash';

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -27,3 +21,3 @@ queueName = 'test-' + v4();

await queue.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -30,0 +24,0 @@

@@ -6,3 +6,3 @@ import { Queue, QueueEvents, Job, Worker, QueueScheduler } from '@src/classes';

import { v4 } from 'uuid';
import { delay } from '@src/utils';
import { delay, removeAllQueueData } from '@src/utils';
import { after, times, once } from 'lodash';

@@ -18,9 +18,3 @@ import { RetryErrors } from '@src/enums';

let queueName: string;
let client: IORedis.Redis;
beforeEach(function() {
client = new IORedis();
return client.flushdb();
});
beforeEach(async function() {

@@ -30,3 +24,3 @@ queueName = 'test-' + v4();

queueEvents = new QueueEvents(queueName);
return queueEvents.waitUntilReady();
await queueEvents.waitUntilReady();
});

@@ -38,3 +32,3 @@

await queueEvents.close();
return client.quit();
await removeAllQueueData(new IORedis(), queueName);
});

@@ -41,0 +35,0 @@

@@ -1,2 +0,3 @@

'use strict';
import IORedis from 'ioredis';
export const errorObject: { [index: string]: any } = { value: null };

@@ -43,1 +44,31 @@

}
export async function removeAllQueueData(
client: IORedis.Redis,
queueName: string,
prefix = 'bull',
) {
const pattern = `${prefix}:${queueName}:*`;
return new Promise((resolve, reject) => {
const stream = client.scanStream({
match: pattern,
});
stream.on('data', (keys: string[]) => {
if (keys.length) {
const pipeline = client.pipeline();
keys.forEach(key => {
pipeline.del(key);
});
pipeline.exec().catch(error => {
reject(error);
});
}
});
stream.on('end', () => {
resolve();
});
stream.on('error', error => {
reject(error);
});
});
}

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

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

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