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

bull

Package Overview
Dependencies
Maintainers
1
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bull - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

26

lib/queue.js

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

this.delayedTimestamp = Number.MAX_VALUE;
this.delayTimer = null;

@@ -120,2 +119,5 @@ this.processing = 0;

//
// Handle delay, pause and resume messages
//
this.eclient.on('message', function(channel, message){

@@ -132,2 +134,13 @@ if(channel === _this.toKey('delayed')){

});
//
// Init delay timestamp.
//
_this.delayedTimestamp = Number.MAX_VALUE;
updateDelaySet(this, Date.now()).then(function(timestamp){
if(timestamp){
_this.updateDelayTimer(timestamp);
}
});
};

@@ -357,10 +370,10 @@

*/
Queue.prototype.updateDelayTimer = function(delayedTimestamp){
Queue.prototype.updateDelayTimer = function(newDelayedTimestamp){
var _this = this;
if(delayedTimestamp < _this.delayedTimestamp){
if(newDelayedTimestamp < _this.delayedTimestamp){
clearTimeout(this.delayTimer);
this.delayedTimestamp = delayedTimestamp;
this.delayedTimestamp = newDelayedTimestamp;
var nextDelayedJob = delayedTimestamp - Date.now();
var nextDelayedJob = newDelayedTimestamp - Date.now();
nextDelayedJob = nextDelayedJob < 0 ? 0 : nextDelayedJob;

@@ -398,4 +411,5 @@

' end',
' return nextTimestamp',
' return', // nextTimestamp',
' end',
' return score',
'end'].join('\n');

@@ -402,0 +416,0 @@

{
"name": "bull",
"version": "0.2.5",
"version": "0.2.6",
"description": "Job manager",

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

"scripts": {
"test": "mocha test/* --reporter spec",
"test": "gulp && mocha test/* --reporter spec",
"postpublish": "git push && git push --tags"
}
}

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

it.skip('process stalled jobs without requiring a queue restart');
it('process stalled jobs without requiring a queue restart');

@@ -714,4 +714,42 @@ it('process a job that fails', function(done){

queue.add({order: 8}, {delay: 800});
});
})
it("should process delayed jobs in correct order even in case of restart", function(done){
var QUEUE_NAME = "delayed queue multiple";
var order = 1;
queue = Queue(QUEUE_NAME);
var fn = function(job, jobDone){
expect(order).to.be.equal(job.data.order);
jobDone();
if (order === 4 ) {
done();
}
order++;
};
Promise.join(
queue.add({order: 2}, {delay: 300}),
queue.add({order: 4}, {delay: 500}),
queue.add({order: 1}, {delay: 200}),
queue.add({order: 3}, {delay: 400})).then(function(){
//
// Start processing so that jobs get into the delay set.
//
queue.process(fn);
}).delay(20).then(function(){
//We simulate a restart
return queue.close().then(function() {
return Promise.delay(100).then(function() {
queue = Queue(QUEUE_NAME);
queue.process(fn);
})
});
});
});
});

@@ -718,0 +756,0 @@

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