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

node-resque

Package Overview
Dependencies
Maintainers
4
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-resque - npm Package Compare versions

Comparing version 9.1.7 to 9.2.0

6

__tests__/core/connection.ts

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

import * as IORedis from "ioredis";
import Redis from "ioredis";
import { Connection } from "../../src";

@@ -38,5 +38,5 @@ import specHelper from "../utils/specHelper";

let prefixedConnection: Connection;
let prefixedRedis: IORedis.Redis;
let prefixedRedis: Redis;
beforeAll(async () => {
prefixedRedis = new IORedis(null, null, {
prefixedRedis = new Redis(null, null, {
keyPrefix: "customNamespace:",

@@ -43,0 +43,0 @@ db: db,

@@ -5,29 +5,33 @@ import { Connection } from "../../src";

describe("connection error", () => {
test("can provide an error if connection failed", async () => {
await new Promise(async (resolve) => {
const connectionDetails = {
pkg: specHelper.connectionDetails.pkg,
host: "wronghostname",
password: specHelper.connectionDetails.password,
port: specHelper.connectionDetails.port,
database: specHelper.connectionDetails.database,
namespace: specHelper.connectionDetails.namespace,
options: { maxRetriesPerRequest: 1 },
};
test(
"can provide an error if connection failed",
async () => {
await new Promise(async (resolve) => {
const connectionDetails = {
pkg: specHelper.connectionDetails.pkg,
host: "wronghostname",
password: specHelper.connectionDetails.password,
port: specHelper.connectionDetails.port,
database: specHelper.connectionDetails.database,
namespace: specHelper.connectionDetails.namespace,
options: { maxRetriesPerRequest: 1 },
};
const brokenConnection = new Connection(connectionDetails);
const brokenConnection = new Connection(connectionDetails);
brokenConnection.on("error", async (error) => {
expect(error.message).toMatch(
/ENOTFOUND|ETIMEDOUT|ECONNREFUSED|EAI_AGAIN/
);
brokenConnection.on("error", async (error) => {
expect(error.message).toMatch(
/ENOTFOUND|ETIMEDOUT|ECONNREFUSED|EAI_AGAIN/
);
});
try {
await brokenConnection.connect();
} catch (error) {
setTimeout(resolve, 3 * 1000);
}
});
try {
await brokenConnection.connect();
} catch (error) {
setTimeout(resolve, 3 * 1000);
}
});
});
},
60 * 1000
);
});

@@ -5,4 +5,4 @@ import { Queue, Worker, Scheduler, Job } from "../../src";

// import * as RedisMock from "ioredis-mock"; // TYPE HACK!
import * as IORedis from "ioredis";
const RedisMock: typeof IORedis = require("ioredis-mock");
import Redis from "ioredis";
const RedisMock: typeof Redis = require("ioredis-mock");

@@ -9,0 +9,0 @@ // for ioredis-mock, we need to re-use a shared connection

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

import * as IORedis from "ioredis";
import Redis from "ioredis";
import * as NodeResque from "../../src/index";

@@ -14,3 +14,3 @@

smallTimeout: 3,
redis: null as IORedis.Redis,
redis: null as Redis,
connectionDetails: {

@@ -30,3 +30,3 @@ pkg: pkg,

this.connectionDetails?.options?.database;
this.redis = new IORedis(
this.redis = new Redis(
this.connectionDetails.port,

@@ -33,0 +33,0 @@ this.connectionDetails.host,

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

if (this.redis && typeof this.redis.scan === "function") {
const [newCursor, matches] = await this.redis.scan(cursor, "match", match, "count", count);
const [newCursor, matches] = await this.redis.scan(cursor, "MATCH", match, "COUNT", count);
if (matches && matches.length > 0) {

@@ -91,0 +91,0 @@ keysAry = keysAry.concat(matches);

/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from "events";

@@ -3,0 +4,0 @@ import { Worker } from "./worker";

/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from "events";

@@ -3,0 +4,0 @@ import { ErrorPayload, Job, Jobs } from "..";

@@ -110,4 +110,4 @@ "use strict";

}
const lockedByMe = await this.connection.redis.set(leaderKey, this.options.name, "NX", "EX", this.options.leaderLockTimeout);
if (lockedByMe && lockedByMe.toLowerCase() === "ok") {
const lockedByMe = await this.connection.redis.set(leaderKey, this.options.name, "EX", this.options.leaderLockTimeout, "NX");
if (lockedByMe && lockedByMe.toUpperCase() === "OK") {
return true;

@@ -114,0 +114,0 @@ }

/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from "events";

@@ -3,0 +4,0 @@ import { Jobs } from "..";

@@ -17,4 +17,4 @@ "use strict";

const timeout = now + this.lockTimeout() + 1;
const lockedByMe = await this.queueObject.connection.redis.set(key, timeout, "NX", "EX", this.lockTimeout());
if (lockedByMe && lockedByMe.toString().toLowerCase() === "ok") {
const lockedByMe = await this.queueObject.connection.redis.set(key, timeout, "EX", this.lockTimeout(), "NX");
if (lockedByMe && lockedByMe.toString().toUpperCase() === "OK") {
return true;

@@ -21,0 +21,0 @@ }

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

/// <reference types="ioredis" />
import { Plugin, Worker, ParsedJob, Queue } from "..";

@@ -15,3 +14,3 @@ export declare class Retry extends Plugin {

maxDelay(): any;
redis(): import("ioredis").Redis | import("ioredis").Cluster;
redis(): import("ioredis/built/cluster").default | import("ioredis/built/Redis").default;
attemptUp(): Promise<number>;

@@ -18,0 +17,0 @@ saveLastError(): Promise<void>;

@@ -6,3 +6,3 @@ {

"license": "Apache-2.0",
"version": "9.1.7",
"version": "9.2.0",
"homepage": "http://github.com/actionhero/node-resque",

@@ -30,16 +30,16 @@ "repository": {

"dependencies": {
"ioredis": "^4.27.6"
"ioredis": "^5.2.1"
},
"devDependencies": {
"@types/ioredis": "^4.26.5",
"@types/jest": "^27.0.1",
"@types/node": "^17.0.1",
"ioredis-mock": "^7.0.0",
"jest": "^27.0.6",
"node-schedule": "^2.0.0",
"prettier": "^2.3.2",
"ts-jest": "^27.0.3",
"ts-node": "^10.1.0",
"typedoc": "^0.22.3",
"typescript": "^4.3.5"
"@types/ioredis": "^4.28.10",
"@types/jest": "^28.1.6",
"@types/node": "^18.0.6",
"ioredis-mock": "^8.2.2",
"jest": "^28.1.3",
"node-schedule": "^2.1.0",
"prettier": "^2.7.1",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"typedoc": "^0.23.8",
"typescript": "^4.7.4"
},

@@ -46,0 +46,0 @@ "scripts": {

@@ -423,3 +423,3 @@ # node-resque: The best background jobs in node.

Because there are no 'heartbeats' in resque, it is imposable for the application to know if a worker has been working on a long job or it is dead. You are required to provide an "age" for how long a worker has been "working", and all those older than that age will be removed, and the job they are working on moved to the error queue (where you can then use `queue.retryAndRemoveFailed`) to re-enqueue the job.
Because there are no 'heartbeats' in resque, it is impossible for the application to know if a worker has been working on a long job or it is dead. You are required to provide an "age" for how long a worker has been "working", and all those older than that age will be removed, and the job they are working on moved to the error queue (where you can then use `queue.retryAndRemoveFailed`) to re-enqueue the job.

@@ -426,0 +426,0 @@ If you know the name of a worker that should be removed, you can also call `await queue.forceCleanWorker(workerName)` directly, and that will also remove the worker and move any job it was working on into the error queue. This method will still proceed for workers which are only partially in redis, indicting a previous connection failure. In this case, the job which the worker was working on is irrecoverably lost.

@@ -122,5 +122,5 @@ import { EventEmitter } from "events";

cursor,
"match",
"MATCH",
match,
"count",
"COUNT",
count

@@ -127,0 +127,0 @@ );

@@ -176,8 +176,8 @@ // To read notes about the leader locking scheme, check out:

this.options.name,
"NX",
"EX",
this.options.leaderLockTimeout
this.options.leaderLockTimeout,
"NX"
);
if (lockedByMe && lockedByMe.toLowerCase() === "ok") {
if (lockedByMe && lockedByMe.toUpperCase() === "OK") {
return true;

@@ -184,0 +184,0 @@ }

@@ -21,7 +21,7 @@ // If a job with the same name, queue, and args is already running, put this job back in the queue and try later

timeout,
"NX",
"EX",
this.lockTimeout()
this.lockTimeout(),
"NX"
);
if (lockedByMe && lockedByMe.toString().toLowerCase() === "ok") {
if (lockedByMe && lockedByMe.toString().toUpperCase() === "OK") {
return true;

@@ -28,0 +28,0 @@ } else {

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