Socket
Socket
Sign inDemoInstall

async-lock

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-lock - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

4

History.md

@@ -0,1 +1,5 @@

1.4.0
==================
* add execution timeout (thank you @mottymilshtein)
1.3.2

@@ -2,0 +6,0 @@ ==================

@@ -26,2 +26,3 @@ 'use strict';

this.maxOccupationTime = opts.maxOccupationTime || AsyncLock.DEFAULT_MAX_OCCUPATION_TIME;
this.maxExecutionTime = opts.maxExecutionTime || AsyncLock.DEFAULT_MAX_EXECUTION_TIME;
if (opts.maxPending === Infinity || (Number.isInteger(opts.maxPending) && opts.maxPending >= 0)) {

@@ -36,2 +37,3 @@ this.maxPending = opts.maxPending;

AsyncLock.DEFAULT_MAX_OCCUPATION_TIME = 0; //Never
AsyncLock.DEFAULT_MAX_EXECUTION_TIME = 0; //Never
AsyncLock.DEFAULT_MAX_PENDING = 1000;

@@ -77,2 +79,3 @@

var occupationTimer = null;
var executionTimer = null;
var self = this;

@@ -87,2 +90,7 @@

if (executionTimer) {
clearTimeout(executionTimer);
executionTimer = null;
}
if (locked) {

@@ -137,2 +145,11 @@ if (!!self.queues[key] && self.queues[key].length === 0) {

var maxExecutionTime = opts.maxExecutionTime || self.maxExecutionTime;
if (maxExecutionTime) {
executionTimer = setTimeout(function () {
if (!!self.queues[key]) {
done(locked, new Error('Maximum execution time is exceeded ' + key));
}
}, maxExecutionTime);
}
// Callback mode

@@ -139,0 +156,0 @@ if (fn.length === 1) {

2

package.json
{
"name": "async-lock",
"description": "Lock on asynchronous code",
"version": "1.3.2",
"version": "1.4.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Rogier Schouten",

@@ -11,2 +11,3 @@ # async-lock

* Occupation time limit supported
* Execution time limit supported
* Pending task limit supported

@@ -142,2 +143,8 @@ * Domain reentrant supported

// Specify max execution time - max amount of time allowed between acquiring the lock and completing execution
var lock = new AsyncLock({maxExecutionTime: 3000});
lock.acquire(key, fn, function(err, ret) {
// execution time exceeded error will be returned here if job not completed in given time
});
// Set max pending tasks - max number of tasks allowed in the queue at a time

@@ -144,0 +151,0 @@ var lock = new AsyncLock({maxPending: 1000});

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