Comparing version 4.1.0 to 4.1.1
@@ -0,1 +1,8 @@ | ||
## [4.1.1](https://github.com/OptimalBits/bull/compare/v4.1.0...v4.1.1) (2021-11-16) | ||
### Bug Fixes | ||
* **emit:** protect emit calls fixes [#2213](https://github.com/OptimalBits/bull/issues/2213) ([4978a2b](https://github.com/OptimalBits/bull/commit/4978a2b40ee840ba91e0939e86e1e3b15e8b16e9)) | ||
# [4.1.0](https://github.com/OptimalBits/bull/compare/v4.0.0...v4.1.0) (2021-10-31) | ||
@@ -2,0 +9,0 @@ |
@@ -15,14 +15,7 @@ /** | ||
const fs = require('fs'); | ||
const fsAsync = require('fs').promises; | ||
const path = require('path'); | ||
const promisify = require('util.promisify'); //TODO in node >= 8 could be removed | ||
const utils = require('../utils'); | ||
//TODO node >= 10 could be used require('fs').promises() | ||
const _fs = { | ||
readdirAsync: promisify(fs.readdir), | ||
readFileAsync: promisify(fs.readFile) | ||
}; | ||
module.exports = (function() { | ||
@@ -42,3 +35,3 @@ let scripts; | ||
async function loadScripts(dir) { | ||
const scriptsDir = await _fs.readdirAsync(dir); | ||
const scriptsDir = await fsAsync.readdir(dir); | ||
const luaFiles = scriptsDir.filter(file => path.extname(file) === '.lua'); | ||
@@ -54,3 +47,3 @@ if (luaFiles.length === 0) { | ||
luaFiles.map(async file => { | ||
const lua = await _fs.readFileAsync(path.join(dir, file)); | ||
const lua = await fsAsync.readFile(path.join(dir, file)); | ||
const longName = path.basename(file, '.lua'); | ||
@@ -57,0 +50,0 @@ |
@@ -12,7 +12,4 @@ /** | ||
//TODO remove for node >= 10 | ||
require('promise.prototype.finally').shim(); | ||
const { promisify } = require('util'); | ||
const promisify = require('util.promisify'); | ||
// same as process.send but waits until the send is complete | ||
@@ -19,0 +16,0 @@ |
'use strict'; | ||
//TODO remove for node >= 10 | ||
require('promise.prototype.finally').shim(); | ||
module.exports = function(processFile, childPool) { | ||
@@ -7,0 +4,0 @@ return function process(job) { |
'use strict'; | ||
//TODO remove for node >= 10 | ||
require('promise.prototype.finally').shim(); | ||
const redis = require('ioredis'); | ||
@@ -21,3 +18,3 @@ const EventEmitter = require('events'); | ||
const TimerManager = require('./timer-manager'); | ||
const promisify = require('util.promisify'); | ||
const { promisify } = require('util'); | ||
const pTimeout = require('p-timeout'); | ||
@@ -402,15 +399,15 @@ const semver = require('semver'); | ||
case activeKey: | ||
this.emit('global:active', message, 'waiting'); | ||
utils.emitSafe(this, 'global:active', message, 'waiting'); | ||
break; | ||
case waitingKey: | ||
if (this.token === token) { | ||
this.emit('waiting', message, null); | ||
utils.emitSafe(this, 'waiting', message, null); | ||
} | ||
token && this.emit('global:waiting', message, null); | ||
token && utils.emitSafe(this, 'global:waiting', message, null); | ||
break; | ||
case stalledKey: | ||
if (this.token === token) { | ||
this.emit('stalled', message); | ||
utils.emitSafe(this, 'stalled', message); | ||
} | ||
this.emit('global:stalled', message); | ||
utils.emitSafe(this, 'global:stalled', message); | ||
break; | ||
@@ -427,3 +424,3 @@ } | ||
const { progress, jobId } = JSON.parse(message); | ||
this.emit('global:progress', jobId, progress); | ||
utils.emitSafe(this, 'global:progress', jobId, progress); | ||
} catch (err) { | ||
@@ -434,3 +431,3 @@ // If we fail we should try to parse the data using the deprecated method | ||
const progress = message.substring(commaPos + 1); | ||
this.emit('global:progress', jobId, JSON.parse(progress)); | ||
utils.emitSafe(this, 'global:progress', jobId, JSON.parse(progress)); | ||
} | ||
@@ -453,7 +450,13 @@ break; | ||
case resumedKey: | ||
this.emit('global:' + message); | ||
utils.emitSafe(this, 'global:' + message); | ||
break; | ||
case completedKey: { | ||
const data = JSON.parse(message); | ||
this.emit('global:completed', data.jobId, data.val, 'active'); | ||
utils.emitSafe( | ||
this, | ||
'global:completed', | ||
data.jobId, | ||
data.val, | ||
'active' | ||
); | ||
break; | ||
@@ -463,7 +466,7 @@ } | ||
const data = JSON.parse(message); | ||
this.emit('global:failed', data.jobId, data.val, 'active'); | ||
utils.emitSafe(this, 'global:failed', data.jobId, data.val, 'active'); | ||
break; | ||
} | ||
case drainedKey: | ||
this.emit('global:drained'); | ||
utils.emitSafe(this, 'global:drained'); | ||
break; | ||
@@ -512,3 +515,3 @@ } | ||
.then(() => { | ||
this.emit('registered:' + eventName); | ||
utils.emitSafe(this, 'registered:' + eventName); | ||
}); | ||
@@ -598,3 +601,3 @@ } else { | ||
this.closed = true; | ||
this.emit('close'); | ||
utils.emitSafe(this, 'close'); | ||
})); | ||
@@ -647,3 +650,3 @@ }; | ||
return this.run(concurrency, name).catch(err => { | ||
this.emit('error', err, 'error running queue'); | ||
utils.emitSafe(this, 'error', err, 'error running queue'); | ||
throw err; | ||
@@ -848,3 +851,3 @@ }); | ||
.then(() => { | ||
return this.emit('paused'); | ||
return utils.emitSafe(this, 'paused'); | ||
}); | ||
@@ -865,3 +868,3 @@ }; | ||
.then(() => { | ||
this.emit('resumed'); | ||
utils.emitSafe(this, 'resumed'); | ||
}); | ||
@@ -956,3 +959,3 @@ }; | ||
.catch(err => { | ||
this.emit('error', err, 'Error updating the delay timer'); | ||
utils.emitSafe(this, 'error', err, 'Error updating the delay timer'); | ||
if (this.delayTimer) { | ||
@@ -984,3 +987,4 @@ clearTimeout(this.delayTimer); | ||
return this.getJobFromId(jobId).then(job => { | ||
this.emit( | ||
utils.emitSafe( | ||
this, | ||
'failed', | ||
@@ -998,3 +1002,3 @@ job, | ||
if (job !== null) { | ||
this.emit('stalled', job); | ||
utils.emitSafe(this, 'stalled', job); | ||
} | ||
@@ -1007,3 +1011,8 @@ return null; | ||
.catch(err => { | ||
this.emit('error', err, 'Failed to handle unlocked job in active'); | ||
utils.emitSafe( | ||
this, | ||
'error', | ||
err, | ||
'Failed to handle unlocked job in active' | ||
); | ||
}); | ||
@@ -1047,3 +1056,3 @@ }; | ||
if (!(this.closing && err.message === 'Connection is closed.')) { | ||
this.emit('error', err, 'Error processing job'); | ||
utils.emitSafe(this, 'error', err, 'Error processing job'); | ||
@@ -1062,3 +1071,3 @@ // | ||
.catch(err => { | ||
this.emit('error', err, 'Error processing job'); | ||
utils.emitSafe(this, 'error', err, 'Error processing job'); | ||
}); | ||
@@ -1099,3 +1108,3 @@ } else { | ||
.catch(err => { | ||
this.emit('lock-extension-failed', job, err); | ||
utils.emitSafe(this, 'lock-extension-failed', job, err); | ||
}); | ||
@@ -1115,3 +1124,3 @@ } | ||
return job.moveToCompleted(result, undefined, notFetch).then(jobData => { | ||
this.emit('completed', job, result, 'active'); | ||
utils.emitSafe(this, 'completed', job, result, 'active'); | ||
return jobData ? this.nextJobFromJobData(jobData[0], jobData[1]) : null; | ||
@@ -1125,3 +1134,3 @@ }); | ||
return job.moveToFailed(err).then(jobData => { | ||
this.emit('failed', job, error, 'active'); | ||
utils.emitSafe(this, 'failed', job, error, 'active'); | ||
return jobData ? this.nextJobFromJobData(jobData[0], jobData[1]) : null; | ||
@@ -1146,3 +1155,3 @@ }); | ||
// Local event with jobPromise so that we can cancel job. | ||
this.emit('active', job, jobPromise, 'waiting'); | ||
utils.emitSafe(this, 'active', job, jobPromise, 'waiting'); | ||
@@ -1218,3 +1227,3 @@ return jobPromise | ||
this.drained = true; | ||
this.emit('drained'); | ||
utils.emitSafe(this, 'drained'); | ||
return null; | ||
@@ -1263,7 +1272,7 @@ } | ||
.then(jobs => { | ||
this.emit('cleaned', jobs, type); | ||
utils.emitSafe(this, 'cleaned', jobs, type); | ||
return jobs; | ||
}) | ||
.catch(err => { | ||
this.emit('error', err); | ||
utils.emitSafe(this, 'error', err); | ||
throw err; | ||
@@ -1270,0 +1279,0 @@ }); |
@@ -48,1 +48,13 @@ 'use strict'; | ||
module.exports.isRedisReady = isRedisReady; | ||
module.exports.emitSafe = function(emitter, event, ...args) { | ||
try { | ||
return emitter.emit(event, ...args); | ||
} catch (err) { | ||
try { | ||
return emitter.emit('error', err); | ||
} catch (err) { | ||
// We give up if the error event also throws an exception. | ||
console.error(err); | ||
} | ||
} | ||
}; |
{ | ||
"name": "bull", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "Job manager", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=10.1" | ||
}, | ||
@@ -29,5 +29,3 @@ "main": "./index.js", | ||
"p-timeout": "^3.2.0", | ||
"promise.prototype.finally": "^3.1.2", | ||
"semver": "^7.3.2", | ||
"util.promisify": "^1.0.1", | ||
"uuid": "^8.3.0" | ||
@@ -34,0 +32,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
175776
8
3303
- Removedpromise.prototype.finally@^3.1.2
- Removedutil.promisify@^1.0.1
- Removedarray-buffer-byte-length@1.0.2(transitive)
- Removedarray.prototype.reduce@1.0.7(transitive)
- Removedarraybuffer.prototype.slice@1.0.4(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removeddata-view-buffer@1.0.2(transitive)
- Removeddata-view-byte-length@1.0.2(transitive)
- Removeddata-view-byte-offset@1.0.1(transitive)
- Removedes-abstract@1.23.7(transitive)
- Removedes-array-method-boxes-properly@1.0.0(transitive)
- Removedes-set-tostringtag@2.0.3(transitive)
- Removedes-to-primitive@1.3.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction.prototype.name@1.1.8(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-symbol-description@1.1.0(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedhas-bigints@1.1.0(transitive)
- Removedhas-proto@1.2.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedinternal-slot@1.1.0(transitive)
- Removedis-array-buffer@3.0.5(transitive)
- Removedis-async-function@2.0.0(transitive)
- Removedis-bigint@1.1.0(transitive)
- Removedis-boolean-object@1.2.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-data-view@1.0.2(transitive)
- Removedis-date-object@1.1.0(transitive)
- Removedis-finalizationregistry@1.1.1(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-map@2.0.3(transitive)
- Removedis-number-object@1.1.1(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedis-set@2.0.3(transitive)
- Removedis-shared-array-buffer@1.0.4(transitive)
- Removedis-string@1.1.1(transitive)
- Removedis-symbol@1.1.1(transitive)
- Removedis-typed-array@1.1.15(transitive)
- Removedis-weakmap@2.0.2(transitive)
- Removedis-weakref@1.1.0(transitive)
- Removedis-weakset@2.0.4(transitive)
- Removedisarray@2.0.5(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject.assign@4.1.7(transitive)
- Removedobject.getownpropertydescriptors@2.1.8(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedpromise.prototype.finally@3.1.8(transitive)
- Removedreflect.getprototypeof@1.0.9(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedsafe-array-concat@1.1.3(transitive)
- Removedsafe-regex-test@1.1.0(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedstring.prototype.trim@1.2.10(transitive)
- Removedstring.prototype.trimend@1.0.9(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedtyped-array-buffer@1.0.3(transitive)
- Removedtyped-array-byte-length@1.0.3(transitive)
- Removedtyped-array-byte-offset@1.0.4(transitive)
- Removedtyped-array-length@1.0.7(transitive)
- Removedunbox-primitive@1.1.0(transitive)
- Removedutil.promisify@1.1.3(transitive)
- Removedwhich-boxed-primitive@1.1.1(transitive)
- Removedwhich-builtin-type@1.2.1(transitive)
- Removedwhich-collection@1.0.2(transitive)
- Removedwhich-typed-array@1.1.18(transitive)