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

tinypool

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinypool - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

33

dist/esm/index.js

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

__publicField(this, "onMessage");
__publicField(this, "shouldRecycle");
this.worker = worker;

@@ -737,5 +738,12 @@ this.workerId = workerId;

shouldRecycleWorker(taskInfo) {
const isWorkerIsolated = this.options.isolateWorkers && taskInfo?.workerInfo;
const isWorkersMemoryLimitReached = !this.options.isolateWorkers && this.options.maxMemoryLimitBeforeRecycle !== void 0 && (taskInfo?.workerInfo?.usedMemory || 0) > this.options.maxMemoryLimitBeforeRecycle;
return Boolean(isWorkerIsolated || isWorkersMemoryLimitReached);
if (taskInfo?.workerInfo?.shouldRecycle) {
return true;
}
if (this.options.isolateWorkers && taskInfo?.workerInfo) {
return true;
}
if (!this.options.isolateWorkers && this.options.maxMemoryLimitBeforeRecycle !== void 0 && (taskInfo?.workerInfo?.usedMemory || 0) > this.options.maxMemoryLimitBeforeRecycle) {
return true;
}
return false;
}

@@ -767,2 +775,18 @@ pendingCapacity() {

}
async recycleWorkers() {
if (this.options.isolateWorkers) {
return;
}
const exitEvents = [];
Array.from(this.workers).filter((workerInfo) => {
if (workerInfo.currentUsage() === 0) {
exitEvents.push(once(workerInfo.worker, "exit"));
this._removeWorker(workerInfo);
} else {
workerInfo.shouldRecycle = true;
}
});
await Promise.all(exitEvents);
this._ensureMinimumWorkers();
}
};

@@ -810,2 +834,5 @@ var _pool;

}
async recycleWorkers() {
await __privateGet(this, _pool).recycleWorkers();
}
get completed() {

@@ -812,0 +839,0 @@ return __privateGet(this, _pool).completed;

@@ -166,2 +166,3 @@ import { MessagePort, Worker } from 'worker_threads';

cancelPendingTasks(): void;
recycleWorkers(): Promise<void>;
get completed(): number;

@@ -168,0 +169,0 @@ get duration(): number;

2

package.json
{
"name": "tinypool",
"version": "0.6.0",
"version": "0.7.0",
"description": "A minimal and tiny Node.js Worker Thread Pool implementation, a fork of piscina, but with fewer features",

@@ -5,0 +5,0 @@ "type": "module",

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