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

bee-queue

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bee-queue - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

6

HISTORY.md

@@ -0,1 +1,7 @@

## [1.7.0](https://github.com/bee-queue/bee-queue/compare/v1.6.0...v1.7.0) (2023-11-06)
### Features
- improve job failure events ([#227](https://github.com/bee-queue/bee-queue/issues/227)) ([15d02c2](https://github.com/bee-queue/bee-queue/commit/15d02c2f7e99505a4a7ce94c12d7311795d28c47))
## [1.6.0](https://github.com/bee-queue/bee-queue/compare/v1.5.0...v1.6.0) (2023-11-02)

@@ -2,0 +8,0 @@

@@ -225,4 +225,21 @@ 'use strict';

}
/**
* Compute the delay for rescheduling the job after it fails.
*
* @return {number} The number of milliseconds into the future to schedule it.
* Negative if no defined strategy or no remaining retries.
*/
computeDelay() {
const strategyName = this.options.backoff
? this.options.backoff.strategy
: 'immediate';
const strategy =
this.options.retries > 0
? this.queue.backoffStrategies.get(strategyName)
: null;
return strategy ? strategy(this) : -1;
}
}
module.exports = Job;

69

lib/queue.js

@@ -594,5 +594,4 @@ 'use strict';

_finishJob(err, data, job) {
const status = err ? 'failed' : 'succeeded';
if (this._isClosed) {
const status = err ? 'failed' : 'succeeded';
throw new Error(`unable to update the status of ${status} job ${job.id}`);

@@ -606,22 +605,13 @@ }

const jobEvent = {
id: job.id,
event: status,
data: err ? err.message : data,
};
const delay = err ? job.computeDelay() : -1;
const status = err ? (delay >= 0 ? 'retrying' : 'failed') : 'succeeded';
job.status = status;
if (err) {
const errInfo = err.stack || err.message || err;
job.options.stacktraces.unshift(errInfo);
}
const strategyName = job.options.backoff
? job.options.backoff.strategy
: 'immediate';
const strategy =
job.options.retries > 0
? this.backoffStrategies.get(strategyName)
: null;
const delay = strategy ? strategy(job) : -1;
if (delay < 0) {
job.status = 'failed';
switch (status) {
case 'failed':
if (this.settings.removeOnFailure) {

@@ -633,6 +623,5 @@ multi.hdel(this.toKey('jobs'), job.id);

}
} else {
job.options.retries -= 1;
job.status = 'retrying';
jobEvent.event = 'retrying';
break;
case 'retrying':
--job.options.retries;
multi.hset(this.toKey('jobs'), job.id, job.toData());

@@ -647,15 +636,22 @@ if (delay === 0) {

}
}
} else {
job.status = 'succeeded';
if (this.settings.removeOnSuccess) {
multi.hdel(this.toKey('jobs'), job.id);
} else {
multi.hset(this.toKey('jobs'), job.id, job.toData());
multi.sadd(this.toKey('succeeded'), job.id);
}
break;
case 'succeeded':
if (this.settings.removeOnSuccess) {
multi.hdel(this.toKey('jobs'), job.id);
} else {
multi.hset(this.toKey('jobs'), job.id, job.toData());
multi.sadd(this.toKey('succeeded'), job.id);
}
break;
}
if (this.settings.sendEvents) {
multi.publish(this.toKey('events'), JSON.stringify(jobEvent));
multi.publish(
this.toKey('events'),
JSON.stringify({
id: job.id,
event: status,
data: err ? err.message : data,
})
);
}

@@ -740,2 +736,13 @@

this.emit(status, job, result);
// Workaround for #184: emit failed event for backwards
// compatibility while affording for a separate event that
// identifies the final failure.
const emitExtra =
status === 'retrying'
? 'failed'
: status === 'failed'
? 'failed:fatal'
: null;
if (emitExtra) this.emit(emitExtra, job, result);
}

@@ -742,0 +749,0 @@ }, this._emitErrorAfterTick);

{
"name": "bee-queue",
"version": "1.6.0",
"version": "1.7.0",
"description": "A simple, fast, robust job/task queue, backed by Redis.",

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

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