Socket
Socket
Sign inDemoInstall

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.5.0 to 0.6.0

dist/esm/chunk-2H7BPY54.js

16

dist/esm/index.js

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

markMovable
} from "./chunk-QYFJIXNO.js";
} from "./chunk-2H7BPY54.js";

@@ -377,2 +377,3 @@ // src/index.ts

__publicField(this, "lastSeenResponseCount", 0);
__publicField(this, "usedMemory");
__publicField(this, "onMessage");

@@ -425,2 +426,3 @@ this.worker = worker;

_handleResponse(message) {
this.usedMemory = message.usedMemory;
this.onMessage(message);

@@ -551,4 +553,5 @@ if (this.taskInfos.size === 0) {

workerInfo.taskInfos.delete(taskId);
if (!this.options.isolateWorkers)
if (!this.shouldRecycleWorker(taskInfo)) {
pool.workers.maybeAvailable(workerInfo);
}
if (taskInfo === void 0) {

@@ -676,4 +679,4 @@ const err = new Error(`Unexpected message from Worker: ${inspect(message2)}`);

}
if (this.options.isolateWorkers && taskInfo.workerInfo) {
this._removeWorker(taskInfo.workerInfo).then(() => this._ensureEnoughWorkersForTaskQueue()).then(() => resolve2(result)).catch(reject);
if (this.shouldRecycleWorker(taskInfo)) {
this._removeWorker(taskInfo.workerInfo).then(() => this._ensureMinimumWorkers()).then(() => this._ensureEnoughWorkersForTaskQueue()).then(() => resolve2(result)).catch(reject);
} else {

@@ -737,2 +740,7 @@ resolve2(result);

}
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);
}
pendingCapacity() {

@@ -739,0 +747,0 @@ return this.workers.pendingItems.size * this.options.concurrentTasksPerWorker;

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

kValue
} from "./chunk-QYFJIXNO.js";
} from "./chunk-2H7BPY54.js";

@@ -118,3 +118,4 @@ // src/worker.ts

result,
error: null
error: null,
usedMemory: process.memoryUsage().heapUsed
};

@@ -131,3 +132,4 @@ if (stdout()?.writableLength > 0) {

result: null,
error
error,
usedMemory: process.memoryUsage().heapUsed
};

@@ -134,0 +136,0 @@ }

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

error: unknown | null;
usedMemory: number;
}

@@ -127,2 +128,3 @@ interface TinypoolPrivateData {

resourceLimits?: ResourceLimits;
maxMemoryLimitBeforeRecycle?: number;
argv?: string[];

@@ -129,0 +131,0 @@ execArgv?: string[];

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

@@ -12,2 +12,3 @@ "type": "module",

],
"packageManager": "pnpm@8.4.0",
"repository": {

@@ -14,0 +15,0 @@ "type": "git",

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