New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pulsecron/pulse

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pulsecron/pulse - npm Package Compare versions

Comparing version 1.6.3 to 1.6.4

4

dist/job/index.js

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

constructor(options) {
const { pulse, type, nextRunAt, ...args } = options ?? {};
const { pulse, type, nextRunAt, repeatAt, repeatInterval, lastFinishedAt, ...args } = options ?? {};
this.pulse = pulse;

@@ -45,3 +45,3 @@ args.priority = args.priority === undefined ? define_1.JobPriority.normal : (0, utils_1.parsePriority)(args.priority);

type: type || 'once',
nextRunAt: nextRunAt || new Date(),
nextRunAt: repeatAt || repeatInterval ? nextRunAt || new Date() : !lastFinishedAt ? nextRunAt || new Date() : nextRunAt,
};

@@ -48,0 +48,0 @@ }

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

const debug_1 = tslib_1.__importDefault(require("debug"));
const job_1 = require("../job");
const debug = (0, debug_1.default)('pulse:resumeOnRestart');

@@ -19,7 +20,10 @@ const resumeOnRestart = function (resume = true) {

nextRunAt: { $ne: null },
$or: [{ $expr: { $eq: ['$runCount', '$finishedCount'] } }, { lastFinishedAt: { $exists: false } }],
$or: [
{ $expr: { $eq: ['$runCount', '$finishedCount'] } },
{ $or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }] },
],
},
{
lockedAt: { $exists: false },
lastFinishedAt: { $exists: false },
$or: [{ lastFinishedAt: { $exists: false } }, { lastFinishedAt: null }],
nextRunAt: { $lte: now, $ne: null },

@@ -34,5 +38,40 @@ },

if (result.modifiedCount > 0) {
debug('resuming unfinished %d jobs(%s)', result.modifiedCount, now.toISOString());
debug('Resumed %d unfinished standard jobs (%s)', result.modifiedCount, now.toISOString());
}
});
this._collection
.find({
$and: [
{ $or: [{ repeatInterval: { $exists: true } }, { repeatAt: { $exists: true } }] },
{ $or: [{ nextRunAt: { $lte: now } }, { nextRunAt: { $exists: false } }, { nextRunAt: null }] },
],
})
.toArray()
.then((jobs) => {
const updates = jobs.map((jobData) => {
const job = new job_1.Job({
pulse: this,
name: jobData.name || '',
data: jobData.data || {},
type: jobData.type || 'normal',
priority: jobData.priority || 'normal',
shouldSaveResult: jobData.shouldSaveResult || false,
attempts: jobData.attempts || 0,
backoff: jobData.backoff,
...jobData,
});
job.computeNextRunAt();
return this._collection.updateOne({ _id: job.attrs._id }, {
$set: { nextRunAt: job.attrs.nextRunAt },
$unset: { lockedAt: undefined, lastModifiedBy: undefined, lastRunAt: undefined },
});
});
return Promise.all(updates);
})
.then((results) => {
const modifiedCount = results.filter((res) => res.modifiedCount > 0).length;
if (modifiedCount > 0) {
debug('Resumed %d recurring jobs (%s)', modifiedCount, now.toISOString());
}
});
}

@@ -39,0 +78,0 @@ return this;

{
"name": "@pulsecron/pulse",
"version": "1.6.3",
"version": "1.6.4",
"description": "The modern MongoDB-powered job scheduler library for Node.js",

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

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