3 All notable changes to this project will be documented in this file.
5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
12 - HTTP server pool examples: express-cluster, express-hybrid.
14 ## [2.6.27] - 2023-08-15
18 - Add `KillHandler` type definition to exported types.
22 - Add `destroy` event to pool API.
24 ## [2.6.26] - 2023-08-15
28 - Add kill handler to worker options allowing to execute custom code when worker is killed.
29 - Add `listTaskFunctions()` method to pool API.
30 - SMTP server pool example: nodemailer.
32 ## [2.6.25] - 2023-08-13
36 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
37 - WebSocket server pool examples: ws-cluster, ws-hybrid.
39 ## [2.6.24] - 2023-08-12
43 - Add array of transferable objects to the `execute()` method arguments.
44 - WebSocket server pool examples: ws-worker_threads.
46 ## [2.6.23] - 2023-08-11
50 - Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker.
54 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
55 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
57 ## [2.6.22] - 2023-08-10
61 - Add missing `types` field to package.json `exports`.
65 - Structure markdown documentation (PR #811).
67 ## [2.6.21] - 2023-08-03
71 - Improve code documentation.
72 - Code refactoring and cleanup for better maintainability and readability.
74 ## [2.6.20] - 2023-07-21
78 - Fix queued tasks redistribution on error task execution starvation.
79 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
83 - Drastically reduce lookups by worker in the worker nodes.
85 ## [2.6.19] - 2023-07-20
89 - Dedicated internal communication channel for worker_threads pools.
91 ## [2.6.18] - 2023-07-19
95 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
97 ## [2.6.17] - 2023-07-16
101 - Add `listTaskFunctions()` method to worker API.
103 ## [2.6.16] - 2023-07-12
107 - Fix pool startup detection.
108 - Fix worker task functions handling.
110 ## [2.6.15] - 2023-07-11
114 - Take into account worker node readiness in worker choice strategies.
116 ## [2.6.14] - 2023-07-10
120 - Fix task function statistics tracking.
122 ## [2.6.13] - 2023-07-10
126 - Add per task function statistics tracking.
127 - Add public methods to manipulate the worker task functions at runtime.
129 ## [2.6.12] - 2023-07-09
133 - Workaround import issue with `node:os` module in node 16.x.x.
135 ## [2.6.11] - 2023-07-09
139 - Fix pool readiness semantic.
141 ## [2.6.10] - 2023-07-08
145 - Ensure workers are not recreated on error at pool startup.
149 - Add `ready` and `strategy` fields to pool information.
150 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
151 - Add dynamic pool sizing checks.
153 ## [2.6.9] - 2023-07-07
157 - Recreate the right worker type on uncaught exception.
161 - Add minimum and maximum to internal measurement statistics.
162 - Add `runTime` and `waitTime` to pool information.
163 - Check worker inactive time only on dynamic worker.
165 ## [2.6.8] - 2023-07-03
169 - Brown paper bag release to fix version handling in pool information.
171 ## [2.6.7] - 2023-07-03
175 - Ensure worker queued tasks at error are reassigned to other pool workers.
179 - Add pool `utilization` ratio to pool information.
180 - Add `version` to pool information.
181 - Add worker information to worker nodes.
183 ## [2.6.6] - 2023-07-01
187 - Add safe helper `availableParallelism` to help sizing the pool.
191 - Ensure message handler is only registered in worker.
193 ## [2.6.5] - 2023-06-27
197 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
201 - Artificial version bump to 2.6.5 to workaround publication issue.
202 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
203 - Ensure pool event is emitted before task error promise rejection.
204 - Fix queued tasks count computation.
208 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
210 ## [2.6.4] - 2023-06-27
214 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
218 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
219 - Ensure pool event is emitted before task error promise rejection.
220 - Fix queued tasks count computation.
224 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
226 ## [2.6.3] - 2023-06-19
230 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
231 - Update strategies internals after statistics computation.
235 - Optimize O(1) queue implementation.
237 ## [2.6.2] - 2023-06-12
241 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
243 ## [2.6.1] - 2023-06-10
247 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
251 - Fix average statistics computation: ensure failed tasks are not accounted.
253 ## [2.6.0] - 2023-06-09
257 - Add `LEAST_ELU` worker choice strategy (experimental).
258 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
262 - Refactor pool worker node usage internals.
263 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
264 - Breaking change: pool information `info` property object fields have been renamed.
268 - Fix wait time accounting.
269 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
270 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
272 ## [2.5.4] - 2023-06-07
276 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
280 - Compute statistics at the worker level only if needed.
281 - Add `worker_threads` options to thread pool options.
285 - Make the `LEAST_BUSY` strategy only relies on task runtime.
287 ## [2.5.3] - 2023-06-04
291 - Refine pool information content.
292 - Limit pool internals public exposure.
294 ## [2.5.2] - 2023-06-02
298 - Add `taskError` pool event for task execution error.
299 - Add pool information `info` property to pool.
300 - Emit pool information on `busy` and `full` pool events.
302 ## [2.5.1] - 2023-06-01
306 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
307 - Add `error` pool event for uncaught worker error.
309 ## [2.5.0] - 2023-05-31
313 - Switch pool event emitter to `EventEmitterAsyncResource`.
314 - Add tasks wait time accounting in per worker tasks usage.
315 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
319 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
321 ## [2.4.14] - 2023-05-09
325 - Ensure no undefined task runtime can land in the tasks history.
326 - Fix median computation implementation once again.
330 - Unit tests for median and queue implementations.
332 ## [2.4.13] - 2023-05-08
336 - Fix worker choice strategy options validation.
337 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
339 ## [2.4.12] - 2023-05-06
343 - Support multiple task functions per worker.
344 - Add custom worker weights support to worker choice strategies options.
348 - Use O(1) queue implementation for tasks queueing.
352 - Fix median computation implementation.
353 - Fix fair share worker choice strategy internals update.
355 ## [2.4.11] - 2023-04-23
359 - Optimize free worker finding in worker choice strategies.
361 ## [2.4.10] - 2023-04-15
365 - Fix typescript type definition for task function: ensure the input data is optional.
366 - Fix typescript type definition for pool execute(): ensure the input data is optional.
368 ## [2.4.9] - 2023-04-15
372 - Add tasks queue enablement runtime setter to pool.
373 - Add tasks queue options runtime setter to pool.
374 - Add worker choice strategy options runtime setter to pool.
378 - Remove the tasks queuing experimental status.
382 - Fix task function type definition and validation.
383 - Fix worker choice strategy options handling.
385 ## [2.4.8] - 2023-04-12
389 - Fix message between main worker and worker type definition for tasks.
390 - Fix code documentation.
392 ## [2.4.7] - 2023-04-11
396 - Add worker tasks queue options to pool options.
400 - Fix missing documentation.
402 ## [2.4.6] - 2023-04-10
406 - Ensure one task at a time is executed per worker with tasks queueing enabled.
407 - Properly count worker executing tasks with tasks queueing enabled.
409 ## [2.4.5] - 2023-04-09
413 - Use monotonic high resolution timer for worker tasks runtime.
414 - Add worker tasks median runtime to statistics.
415 - Add worker tasks queue (experimental).
417 ## [2.4.4] - 2023-04-07
421 - Add `PoolEvents` enumeration and `PoolEvent` type.
425 - Destroy worker only on alive check.
427 ## [2.4.3] - 2023-04-07
431 - Fix typedoc generation with inheritance.
433 ## [2.4.2] - 2023-04-06
437 - Add `full` event to dynamic pool.
438 - Keep worker choice strategy in memory for conditional reuse.
442 - Fix possible negative worker key at worker removal in worker choice strategies.
444 ## [2.4.1] - 2023-04-05
448 - Optimize worker choice strategy for dynamic pool.
452 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
454 ## [2.4.0] - 2023-04-04
458 - Add `LESS_BUSY` worker choice strategy.
462 - Optimize worker storage in pool.
463 - Optimize worker alive status check.
464 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
465 - Optimize `LESS_USED` worker choice strategy.
466 - Update benchmarks versus external threads pools.
467 - Optimize tasks usage statistics requirements for worker choice strategy.
471 - Ensure trimmable characters are checked at pool initialization.
472 - Fix message id integer overflow.
473 - Fix pool worker removal in worker choice strategy internals.
474 - Fix package publication with pnpm.
476 ## [2.4.0-3] - 2023-04-04
480 - Add `LESS_BUSY` worker choice strategy.
484 - Optimize worker storage in pool.
485 - Optimize worker alive status check.
486 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
487 - Optimize `LESS_USED` worker choice strategy.
488 - Update benchmarks versus external threads pools.
492 - Ensure trimmable characters are checked at pool initialization.
493 - Fix message id integer overflow.
494 - Fix pool worker removal in worker choice strategy internals.
495 - Fix package publication with pnpm.
497 ## [2.4.0-2] - 2023-04-03
501 - Add `LESS_BUSY` worker choice strategy.
505 - Optimize worker storage in pool.
506 - Optimize worker alive status check.
507 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
508 - Optimize `LESS_USED` worker choice strategy.
512 - Ensure trimmable characters are checked at pool initialization.
513 - Fix message id integer overflow.
514 - Fix pool worker removal in worker choice strategy internals.
515 - Fix package publication with pnpm.
517 ## [2.4.0-1] - 2023-04-03
521 - Add `LESS_BUSY` worker choice strategy.
525 - Optimize worker storage in pool.
526 - Optimize worker alive status check.
527 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
528 - Optimize `LESS_USED` worker choice strategy.
532 - Ensure trimmable characters are checked at pool initialization.
533 - Fix message id integer overflow.
534 - Fix pool worker removal in worker choice strategy internals.
536 ## [2.4.0-0] - 2023-04-03
540 - Add `LESS_BUSY` worker choice strategy.
544 - Optimize worker storage in pool.
545 - Optimize worker alive status check.
546 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
547 - Optimize `LESS_USED` worker choice strategy.
551 - Ensure trimmable characters are checked at pool initialization.
552 - Fix message id integer overflow.
553 - Fix pool worker removal in worker choice strategy internals.
555 ## [2.3.10] - 2023-03-18
559 - Fix package.json `exports` syntax for ESM and CommonJS.
563 - Permit SemVer pre-release publication.
565 ## [2.3.10-2] - 2023-03-18
569 - Fix package.json `exports` syntax for ESM and CommonJS.
571 ## [2.3.10-1] - 2023-03-18
575 - Permit SemVer pre-release publication.
577 ## [2.3.10-0] - 2023-03-18
581 - Fix package.json `exports` syntax for ESM and CommonJS.
583 ## [2.3.9] - 2023-03-18
587 - Introduce ESM module support along with CommonJS one.
591 - Fix brown paper bag bug referencing the same object literal.
593 ## [2.3.8] - 2023-03-18
597 - Switch internal benchmarking code to benny.
598 - Switch to TypeScript 5.x.x.
599 - Switch rollup bundler plugins to core ones.
600 - Switch to TSDoc syntax.
601 - Enforce conventional commits.
605 - Fix random integer generator.
606 - Fix worker choice strategy pool type identification at initialization.
608 ## [2.3.7] - 2022-10-23
612 - Switch to open collective FOSS project funding platform.
613 - Switch to ts-standard linter configuration on TypeScript code.
617 - Fixed missing async on pool execute method.
618 - Fixed typing in TypeScript example.
619 - Fixed types in unit tests.
621 ## [2.3.6] - 2022-10-22
625 - Cleanup pool attributes and methods.
626 - Refine error types thrown.
630 - Fix continuous integration build on windows.
631 - Fix code coverage reporting by using c8 instead of nyc.
633 ## [2.3.5] - 2022-10-21
637 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
638 - Optimize tasks usage lookup implementation.
642 - Fix missed pool event emitter type export.
643 - Fix typedoc documentation generation.
645 ## [2.3.4] - 2022-10-17
649 - Fully automate release process with release-it.
653 - Optimize fair share task scheduling algorithm implementation.
654 - Update benchmarks versus external pools results with latest version.
656 ## [2.3.3] - 2022-10-15
660 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
662 ## [2.3.2] - 2022-10-14
666 - Optimize fair share worker selection strategy implementation.
670 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
672 ## [2.3.1] - 2022-10-13
676 - Pool worker choice strategies:
677 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
678 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
680 ## [2.2.2] - 2022-10-09
684 - Fixed `README.md` file.
686 ## [2.2.1] - 2022-10-08
690 - Dynamic worker choice strategy change at runtime.
692 ## [2.2.0] - 2022-01-05
696 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
698 ## [2.1.0] - 2021-08-29
702 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
706 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
707 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
708 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
709 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
711 ## [2.0.2] - 2021-05-12
715 - Fix `busy` event emission on fixed pool type
717 ## [2.0.1] - 2021-03-16
721 - Check if pool options are properly set.
722 - `busy` event is emitted on all pool types.
724 ## [2.0.0] - 2021-03-01
728 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
732 - `FullPool` event is now renamed to `busy`.
733 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
734 _Find more details on our JSDoc._
736 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
738 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
740 ### Pool options types declaration merge
742 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
744 #### New `export` strategy
748 const DynamicThreadPool = require('poolifier/lib/dynamic')
750 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
753 But you should always prefer just using
756 const { DynamicThreadPool } = require('poolifier')
759 #### New type definitions for input data and response
761 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
762 _This is not a limitation by poolifier but Node.js._
764 #### Public property replacements
766 `numWorkers` property is now `numberOfWorkers`
768 #### Internal (protected) properties and methods renaming
770 These properties are not intended for end users
772 - `id` => `nextMessageId`
774 These methods are not intended for end users
776 - `_chooseWorker` => `chooseWorker`
777 - `_newWorker` => `createWorker`
778 - `_execute` => `internalExecute`
779 - `_chooseWorker` => `chooseWorker`
780 - `_checkAlive` => `checkAlive`
782 - `_runAsync` => `runAsync`
784 ## [1.1.0] - 2020-05-21
788 - ThreadWorker support async functions as option
789 - Various external library patches
791 ## [1.0.0] - 2020-01-24
795 - FixedThreadPool implementation
796 - DynamicThreadPool implementation
797 - WorkerThread implementation to improve developer experience