build: refine linter configuration
[poolifier.git] / CHANGELOG.md
1 # Changelog
2
3 All notable changes to this project will be documented in this file.
4
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).
7
8 ## [Unreleased]
9
10 ### Fixed
11
12 - Add `KillHandler` type definition to exported types.
13
14 ### Added
15
16 - Add `destroy` event to pool API.
17
18 ## [2.6.26] - 2023-08-15
19
20 ### Added
21
22 - Add kill handler to worker options allowing to execute custom code when worker is killed.
23 - Add `listTaskFunctions()` method to pool API.
24 - SMTP server pool example: nodemailer.
25
26 ## [2.6.25] - 2023-08-13
27
28 ### Added
29
30 - HTTP server pool examples: fastify-cluster, fastify-hybrid.
31 - WebSocket server pool examples: ws-cluster, ws-hybrid.
32
33 ## [2.6.24] - 2023-08-12
34
35 ### Added
36
37 - Add array of transferable objects to the `execute()` method arguments.
38 - WebSocket server pool examples: ws-worker_threads.
39
40 ## [2.6.23] - 2023-08-11
41
42 ### Fixed
43
44 - 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.
45
46 ### Added
47
48 - HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
49 - HTTP server pool examples: express-worker_threads, fastify-worker_threads.
50
51 ## [2.6.22] - 2023-08-10
52
53 ### Fixed
54
55 - Add missing `types` field to package.json `exports`.
56
57 ### Changed
58
59 - Structure markdown documentation (PR #811).
60
61 ## [2.6.21] - 2023-08-03
62
63 ### Changed
64
65 - Improve code documentation.
66 - Code refactoring and cleanup for better maintainability and readability.
67
68 ## [2.6.20] - 2023-07-21
69
70 ### Fixed
71
72 - Fix queued tasks redistribution on error task execution starvation.
73 - Ensure task queueing per worker condition is untangled from the pool busyness semantic.
74
75 ### Changed
76
77 - Drastically reduce lookups by worker in the worker nodes.
78
79 ## [2.6.19] - 2023-07-20
80
81 ### Added
82
83 - Dedicated internal communication channel for worker_threads pools.
84
85 ## [2.6.18] - 2023-07-19
86
87 ### Changed
88
89 - Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
90
91 ## [2.6.17] - 2023-07-16
92
93 ### Added
94
95 - Add `listTaskFunctions()` method to worker API.
96
97 ## [2.6.16] - 2023-07-12
98
99 ### Fixed
100
101 - Fix pool startup detection.
102 - Fix worker task functions handling.
103
104 ## [2.6.15] - 2023-07-11
105
106 ### Added
107
108 - Take into account worker node readiness in worker choice strategies.
109
110 ## [2.6.14] - 2023-07-10
111
112 ### Fixed
113
114 - Fix task function statistics tracking.
115
116 ## [2.6.13] - 2023-07-10
117
118 ### Added
119
120 - Add per task function statistics tracking.
121 - Add public methods to manipulate the worker task functions at runtime.
122
123 ## [2.6.12] - 2023-07-09
124
125 ### Fixed
126
127 - Workaround import issue with `node:os` module in node 16.x.x.
128
129 ## [2.6.11] - 2023-07-09
130
131 ### Fixed
132
133 - Fix pool readiness semantic.
134
135 ## [2.6.10] - 2023-07-08
136
137 ### Fixed
138
139 - Ensure workers are not recreated on error at pool startup.
140
141 ### Added
142
143 - Add `ready` and `strategy` fields to pool information.
144 - Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
145 - Add dynamic pool sizing checks.
146
147 ## [2.6.9] - 2023-07-07
148
149 ### Fixed
150
151 - Recreate the right worker type on uncaught exception.
152
153 ### Added
154
155 - Add minimum and maximum to internal measurement statistics.
156 - Add `runTime` and `waitTime` to pool information.
157 - Check worker inactive time only on dynamic worker.
158
159 ## [2.6.8] - 2023-07-03
160
161 ### Fixed
162
163 - Brown paper bag release to fix version handling in pool information.
164
165 ## [2.6.7] - 2023-07-03
166
167 ### Fixed
168
169 - Ensure worker queued tasks at error are reassigned to other pool workers.
170
171 ### Added
172
173 - Add pool `utilization` ratio to pool information.
174 - Add `version` to pool information.
175 - Add worker information to worker nodes.
176
177 ## [2.6.6] - 2023-07-01
178
179 ### Added
180
181 - Add safe helper `availableParallelism` to help sizing the pool.
182
183 ### Fixed
184
185 - Ensure message handler is only registered in worker.
186
187 ## [2.6.5] - 2023-06-27
188
189 ### Known issues
190
191 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
192
193 ### Fixed
194
195 - Artificial version bump to 2.6.5 to workaround publication issue.
196 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
197 - Ensure pool event is emitted before task error promise rejection.
198 - Fix queued tasks count computation.
199
200 ### Removed
201
202 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
203
204 ## [2.6.4] - 2023-06-27
205
206 ### Known issues
207
208 - Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
209
210 ### Fixed
211
212 - Ensure cluster pool destroy() gracefully shutdowns worker's server.
213 - Ensure pool event is emitted before task error promise rejection.
214 - Fix queued tasks count computation.
215
216 ### Removed
217
218 - Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
219
220 ## [2.6.3] - 2023-06-19
221
222 ### Fixed
223
224 - Ensure no tasks are queued when trying to soft kill a dynamic worker.
225 - Update strategies internals after statistics computation.
226
227 ### Changed
228
229 - Optimize O(1) queue implementation.
230
231 ## [2.6.2] - 2023-06-12
232
233 ### Fixed
234
235 - Fix new worker use after creation in dynamic pool given the current worker choice strategy.
236
237 ## [2.6.1] - 2023-06-10
238
239 ### Added
240
241 - Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
242
243 ### Fixed
244
245 - Fix average statistics computation: ensure failed tasks are not accounted.
246
247 ## [2.6.0] - 2023-06-09
248
249 ### Added
250
251 - Add `LEAST_ELU` worker choice strategy (experimental).
252 - Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
253
254 ### Changed
255
256 - Refactor pool worker node usage internals.
257 - Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
258 - Breaking change: pool information `info` property object fields have been renamed.
259
260 ### Fixed
261
262 - Fix wait time accounting.
263 - Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
264 - Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
265
266 ## [2.5.4] - 2023-06-07
267
268 ### Added
269
270 - Add Event Loop Utilization (ELU) statistics to worker tasks usage.
271
272 ### Changed
273
274 - Compute statistics at the worker level only if needed.
275 - Add `worker_threads` options to thread pool options.
276
277 ### Fixed
278
279 - Make the `LEAST_BUSY` strategy only relies on task runtime.
280
281 ## [2.5.3] - 2023-06-04
282
283 ### Changed
284
285 - Refine pool information content.
286 - Limit pool internals public exposure.
287
288 ## [2.5.2] - 2023-06-02
289
290 ### Added
291
292 - Add `taskError` pool event for task execution error.
293 - Add pool information `info` property to pool.
294 - Emit pool information on `busy` and `full` pool events.
295
296 ## [2.5.1] - 2023-06-01
297
298 ### Added
299
300 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
301 - Add `error` pool event for uncaught worker error.
302
303 ## [2.5.0] - 2023-05-31
304
305 ### Added
306
307 - Switch pool event emitter to `EventEmitterAsyncResource`.
308 - Add tasks wait time accounting in per worker tasks usage.
309 - Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
310
311 ### Changed
312
313 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
314
315 ## [2.4.14] - 2023-05-09
316
317 ### Fixed
318
319 - Ensure no undefined task runtime can land in the tasks history.
320 - Fix median computation implementation once again.
321
322 ### Added
323
324 - Unit tests for median and queue implementations.
325
326 ## [2.4.13] - 2023-05-08
327
328 ### Fixed
329
330 - Fix worker choice strategy options validation.
331 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
332
333 ## [2.4.12] - 2023-05-06
334
335 ### Added
336
337 - Support multiple task functions per worker.
338 - Add custom worker weights support to worker choice strategies options.
339
340 ### Changed
341
342 - Use O(1) queue implementation for tasks queueing.
343
344 ### Fixed
345
346 - Fix median computation implementation.
347 - Fix fair share worker choice strategy internals update.
348
349 ## [2.4.11] - 2023-04-23
350
351 ### Changed
352
353 - Optimize free worker finding in worker choice strategies.
354
355 ## [2.4.10] - 2023-04-15
356
357 ### Fixed
358
359 - Fix typescript type definition for task function: ensure the input data is optional.
360 - Fix typescript type definition for pool execute(): ensure the input data is optional.
361
362 ## [2.4.9] - 2023-04-15
363
364 ### Added
365
366 - Add tasks queue enablement runtime setter to pool.
367 - Add tasks queue options runtime setter to pool.
368 - Add worker choice strategy options runtime setter to pool.
369
370 ### Changed
371
372 - Remove the tasks queuing experimental status.
373
374 ### Fixed
375
376 - Fix task function type definition and validation.
377 - Fix worker choice strategy options handling.
378
379 ## [2.4.8] - 2023-04-12
380
381 ### Fixed
382
383 - Fix message between main worker and worker type definition for tasks.
384 - Fix code documentation.
385
386 ## [2.4.7] - 2023-04-11
387
388 ### Added
389
390 - Add worker tasks queue options to pool options.
391
392 ### Fixed
393
394 - Fix missing documentation.
395
396 ## [2.4.6] - 2023-04-10
397
398 ### Fixed
399
400 - Ensure one task at a time is executed per worker with tasks queueing enabled.
401 - Properly count worker executing tasks with tasks queueing enabled.
402
403 ## [2.4.5] - 2023-04-09
404
405 ### Added
406
407 - Use monotonic high resolution timer for worker tasks runtime.
408 - Add worker tasks median runtime to statistics.
409 - Add worker tasks queue (experimental).
410
411 ## [2.4.4] - 2023-04-07
412
413 ### Added
414
415 - Add `PoolEvents` enumeration and `PoolEvent` type.
416
417 ### Fixed
418
419 - Destroy worker only on alive check.
420
421 ## [2.4.3] - 2023-04-07
422
423 ### Fixed
424
425 - Fix typedoc generation with inheritance.
426
427 ## [2.4.2] - 2023-04-06
428
429 ### Added
430
431 - Add `full` event to dynamic pool.
432 - Keep worker choice strategy in memory for conditional reuse.
433
434 ### Fixed
435
436 - Fix possible negative worker key at worker removal in worker choice strategies.
437
438 ## [2.4.1] - 2023-04-05
439
440 ### Changed
441
442 - Optimize worker choice strategy for dynamic pool.
443
444 ### Fixed
445
446 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
447
448 ## [2.4.0] - 2023-04-04
449
450 ### Added
451
452 - Add `LESS_BUSY` worker choice strategy.
453
454 ### Changed
455
456 - Optimize worker storage in pool.
457 - Optimize worker alive status check.
458 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
459 - Optimize `LESS_USED` worker choice strategy.
460 - Update benchmarks versus external threads pools.
461 - Optimize tasks usage statistics requirements for worker choice strategy.
462
463 ### Fixed
464
465 - Ensure trimmable characters are checked at pool initialization.
466 - Fix message id integer overflow.
467 - Fix pool worker removal in worker choice strategy internals.
468 - Fix package publication with pnpm.
469
470 ## [2.4.0-3] - 2023-04-04
471
472 ### Added
473
474 - Add `LESS_BUSY` worker choice strategy.
475
476 ### Changed
477
478 - Optimize worker storage in pool.
479 - Optimize worker alive status check.
480 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
481 - Optimize `LESS_USED` worker choice strategy.
482 - Update benchmarks versus external threads pools.
483
484 ### Fixed
485
486 - Ensure trimmable characters are checked at pool initialization.
487 - Fix message id integer overflow.
488 - Fix pool worker removal in worker choice strategy internals.
489 - Fix package publication with pnpm.
490
491 ## [2.4.0-2] - 2023-04-03
492
493 ### Added
494
495 - Add `LESS_BUSY` worker choice strategy.
496
497 ### Changed
498
499 - Optimize worker storage in pool.
500 - Optimize worker alive status check.
501 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
502 - Optimize `LESS_USED` worker choice strategy.
503
504 ### Fixed
505
506 - Ensure trimmable characters are checked at pool initialization.
507 - Fix message id integer overflow.
508 - Fix pool worker removal in worker choice strategy internals.
509 - Fix package publication with pnpm.
510
511 ## [2.4.0-1] - 2023-04-03
512
513 ### Added
514
515 - Add `LESS_BUSY` worker choice strategy.
516
517 ### Changed
518
519 - Optimize worker storage in pool.
520 - Optimize worker alive status check.
521 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
522 - Optimize `LESS_USED` worker choice strategy.
523
524 ### Fixed
525
526 - Ensure trimmable characters are checked at pool initialization.
527 - Fix message id integer overflow.
528 - Fix pool worker removal in worker choice strategy internals.
529
530 ## [2.4.0-0] - 2023-04-03
531
532 ### Added
533
534 - Add `LESS_BUSY` worker choice strategy.
535
536 ### Changed
537
538 - Optimize worker storage in pool.
539 - Optimize worker alive status check.
540 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
541 - Optimize `LESS_USED` worker choice strategy.
542
543 ### Fixed
544
545 - Ensure trimmable characters are checked at pool initialization.
546 - Fix message id integer overflow.
547 - Fix pool worker removal in worker choice strategy internals.
548
549 ## [2.3.10] - 2023-03-18
550
551 ### Fixed
552
553 - Fix package.json `exports` syntax for ESM and CommonJS.
554
555 ### Changed
556
557 - Permit SemVer pre-release publication.
558
559 ## [2.3.10-2] - 2023-03-18
560
561 ### Fixed
562
563 - Fix package.json `exports` syntax for ESM and CommonJS.
564
565 ## [2.3.10-1] - 2023-03-18
566
567 ### Changed
568
569 - Permit SemVer pre-release publication.
570
571 ## [2.3.10-0] - 2023-03-18
572
573 ### Fixed
574
575 - Fix package.json `exports` syntax for ESM and CommonJS.
576
577 ## [2.3.9] - 2023-03-18
578
579 ### Changed
580
581 - Introduce ESM module support along with CommonJS one.
582
583 ### Fixed
584
585 - Fix brown paper bag bug referencing the same object literal.
586
587 ## [2.3.8] - 2023-03-18
588
589 ### Changed
590
591 - Switch internal benchmarking code to benny.
592 - Switch to TypeScript 5.x.x.
593 - Switch rollup bundler plugins to core ones.
594 - Switch to TSDoc syntax.
595 - Enforce conventional commits.
596
597 ### Fixed
598
599 - Fix random integer generator.
600 - Fix worker choice strategy pool type identification at initialization.
601
602 ## [2.3.7] - 2022-10-23
603
604 ### Changed
605
606 - Switch to open collective FOSS project funding platform.
607 - Switch to ts-standard linter configuration on TypeScript code.
608
609 ### Fixed
610
611 - Fixed missing async on pool execute method.
612 - Fixed typing in TypeScript example.
613 - Fixed types in unit tests.
614
615 ## [2.3.6] - 2022-10-22
616
617 ### Changed
618
619 - Cleanup pool attributes and methods.
620 - Refine error types thrown.
621
622 ### Fixed
623
624 - Fix continuous integration build on windows.
625 - Fix code coverage reporting by using c8 instead of nyc.
626
627 ## [2.3.5] - 2022-10-21
628
629 ### Changed
630
631 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
632 - Optimize tasks usage lookup implementation.
633
634 ### Fixed
635
636 - Fix missed pool event emitter type export.
637 - Fix typedoc documentation generation.
638
639 ## [2.3.4] - 2022-10-17
640
641 ### Added
642
643 - Fully automate release process with release-it.
644
645 ### Changed
646
647 - Optimize fair share task scheduling algorithm implementation.
648 - Update benchmarks versus external pools results with latest version.
649
650 ## [2.3.3] - 2022-10-15
651
652 ### Added
653
654 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
655
656 ## [2.3.2] - 2022-10-14
657
658 ### Changed
659
660 - Optimize fair share worker selection strategy implementation.
661
662 ### Fixed
663
664 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
665
666 ## [2.3.1] - 2022-10-13
667
668 ### Added
669
670 - Pool worker choice strategies:
671 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
672 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
673
674 ## [2.2.2] - 2022-10-09
675
676 ### Fixed
677
678 - Fixed `README.md` file.
679
680 ## [2.2.1] - 2022-10-08
681
682 ### Added
683
684 - Dynamic worker choice strategy change at runtime.
685
686 ## [2.2.0] - 2022-01-05
687
688 ### Breaking Changes
689
690 - Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
691
692 ## [2.1.0] - 2021-08-29
693
694 ### Added
695
696 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
697
698 ### Breaking Changes
699
700 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
701 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
702 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
703 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
704
705 ## [2.0.2] - 2021-05-12
706
707 ### Bug fixes
708
709 - Fix `busy` event emission on fixed pool type
710
711 ## [2.0.1] - 2021-03-16
712
713 ### Bug fixes
714
715 - Check if pool options are properly set.
716 - `busy` event is emitted on all pool types.
717
718 ## [2.0.0] - 2021-03-01
719
720 ### Bug fixes
721
722 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
723
724 ### Breaking Changes
725
726 - `FullPool` event is now renamed to `busy`.
727 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
728 _Find more details on our JSDoc._
729
730 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
731
732 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
733
734 ### Pool options types declaration merge
735
736 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
737
738 #### New `export` strategy
739
740 ```js
741 // Before
742 const DynamicThreadPool = require('poolifier/lib/dynamic')
743 // After
744 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
745 ```
746
747 But you should always prefer just using
748
749 ```js
750 const { DynamicThreadPool } = require('poolifier')
751 ```
752
753 #### New type definitions for input data and response
754
755 For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
756 _This is not a limitation by poolifier but Node.js._
757
758 #### Public property replacements
759
760 `numWorkers` property is now `numberOfWorkers`
761
762 #### Internal (protected) properties and methods renaming
763
764 These properties are not intended for end users
765
766 - `id` => `nextMessageId`
767
768 These methods are not intended for end users
769
770 - `_chooseWorker` => `chooseWorker`
771 - `_newWorker` => `createWorker`
772 - `_execute` => `internalExecute`
773 - `_chooseWorker` => `chooseWorker`
774 - `_checkAlive` => `checkAlive`
775 - `_run` => `run`
776 - `_runAsync` => `runAsync`
777
778 ## [1.1.0] - 2020-05-21
779
780 ### Added
781
782 - ThreadWorker support async functions as option
783 - Various external library patches
784
785 ## [1.0.0] - 2020-01-24
786
787 ### Added
788
789 - FixedThreadPool implementation
790 - DynamicThreadPool implementation
791 - WorkerThread implementation to improve developer experience