A worker for extracting package tarballs to the store using multi-threaded worker pools for high-performance package management operations
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Core worker pool lifecycle management for controlling the multi-threaded processing system used by @pnpm/worker.
Restarts the worker pool by finishing current workers and creating a new pool. This is useful for resetting the worker state or applying configuration changes.
/**
* Restarts the worker pool by finishing current workers and creating a new pool
* @returns Promise that resolves when the worker pool has been restarted
*/
function restartWorkerPool(): Promise<void>;Usage Example:
import { restartWorkerPool } from "@pnpm/worker";
// Restart the worker pool (e.g., after configuration changes)
await restartWorkerPool();
console.log("Worker pool restarted successfully");Finishes all active workers in the pool. This should be called before process termination to ensure all workers complete their current tasks gracefully.
/**
* Finishes all active workers in the pool
* @returns Promise that resolves when all workers have finished
*/
function finishWorkers(): Promise<void>;Usage Example:
import { finishWorkers } from "@pnpm/worker";
// Gracefully shutdown all workers before process exit
process.on('SIGTERM', async () => {
await finishWorkers();
process.exit(0);
});The worker pool is automatically created when needed and uses the following configuration:
availableParallelism() - 1 or configured via PNPM_WORKERS environment variableworker.js compiled from worker.ts@rushstack/worker-pool for robust worker managementThe PNPM_WORKERS environment variable can be set to control the number of idle CPUs to reserve:
max(2, availableParallelism() - abs(PNPM_WORKERS)) - 1max(1, availableParallelism() - 1)Install with Tessl CLI
npx tessl i tessl/npm-pnpm--worker