From 1e453b0f9c372445a9f191f1c1d11bcb5532c1d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 8 Jul 2025 16:14:43 +0200 Subject: [PATCH] fix: ensure dynamic worker can't be created at pool destroy (#2916) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * fix: ensure dynamic worker can't be created at pool destroy Signed-off-by: Jérôme Benoit * refactor: increase default task finished timeout value Signed-off-by: Jérôme Benoit * test: fix task queue options expectation Signed-off-by: Jérôme Benoit * refactor: remove dead code Signed-off-by: Jérôme Benoit * docs: update for task timeout value change Signed-off-by: Jérôme Benoit * refactor: test with larger task timeout Signed-off-by: Jérôme Benoit * fix: filter worker kill message reponse where appropriate Signed-off-by: Jérôme Benoit * fix: filter late worker ready message Signed-off-by: Jérôme Benoit * fix: move kill response checks to listener Signed-off-by: Jérôme Benoit * refactor: remove unneeded close guards Signed-off-by: Jérôme Benoit * fix: remove unneeded worker id check a kill message handling Signed-off-by: Jérôme Benoit * fix: add timeout at worker kill response handling Signed-off-by: Jérôme Benoit * refactor: cleanup message handling code Signed-off-by: Jérôme Benoit * refactor: revert to initial task timeout value Signed-off-by: Jérôme Benoit * chore(deps-dev): apply updates Signed-off-by: Jérôme Benoit * fix: be safe at listener registering Signed-off-by: Jérôme Benoit --------- Signed-off-by: Jérôme Benoit --- biome.json | 2 +- package.json | 2 +- pnpm-lock.yaml | 224 +++++++++++++++++------------------ src/pools/abstract-pool.ts | 93 +++++++++------ src/pools/cluster/dynamic.ts | 6 +- src/pools/cluster/fixed.ts | 4 +- src/pools/thread/dynamic.ts | 6 +- src/pools/thread/fixed.ts | 4 +- 8 files changed, 185 insertions(+), 156 deletions(-) diff --git a/biome.json b/biome.json index f5be02145..8fa568df4 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.0.6/schema.json", + "$schema": "https://biomejs.dev/schemas/2.1.0/schema.json", "assist": { "actions": { "source": { "organizeImports": "off" } } }, "linter": { "enabled": false, diff --git a/package.json b/package.json index 67a5b789c..1dc9e2bee 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ } }, "devDependencies": { - "@biomejs/biome": "^2.0.6", + "@biomejs/biome": "^2.1.0", "@commitlint/cli": "^19.8.1", "@commitlint/config-conventional": "^19.8.1", "@cspell/eslint-plugin": "^9.1.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b96430372..e4b830203 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: .: devDependencies: '@biomejs/biome': - specifier: ^2.0.6 - version: 2.0.6 + specifier: ^2.1.0 + version: 2.1.0 '@commitlint/cli': specifier: ^19.8.1 version: 19.8.1(@types/node@24.0.10)(typescript@5.8.3) @@ -73,7 +73,7 @@ importers: version: 7.1.3(mocha@11.7.1) neostandard: specifier: ^0.12.2 - version: 0.12.2(@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + version: 0.12.2(@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) prettier: specifier: ^3.6.2 version: 3.6.2 @@ -120,55 +120,55 @@ packages: resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} - '@biomejs/biome@2.0.6': - resolution: {integrity: sha512-RRP+9cdh5qwe2t0gORwXaa27oTOiQRQvrFf49x2PA1tnpsyU7FIHX4ZOFMtBC4QNtyWsN7Dqkf5EDbg4X+9iqA==} + '@biomejs/biome@2.1.0': + resolution: {integrity: sha512-K2UDr1dCiaOWegp4yQLMC4Evgl85ze1O7r+WxPeO7cNl0XrIcTshvdQGMDB23c/2afXz6RsOKYfWLErNbBbjmA==} engines: {node: '>=14.21.3'} hasBin: true - '@biomejs/cli-darwin-arm64@2.0.6': - resolution: {integrity: sha512-AzdiNNjNzsE6LfqWyBvcL29uWoIuZUkndu+wwlXW13EKcBHbbKjNQEZIJKYDc6IL+p7bmWGx3v9ZtcRyIoIz5A==} + '@biomejs/cli-darwin-arm64@2.1.0': + resolution: {integrity: sha512-RDXEUGSCvUx3PKWRt95WRtwH+l01slm7r2zaotDwWERn/RITMcdet21rI5q5cYhL4XJiAvLHG8qyLNSXqIOCwQ==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [darwin] - '@biomejs/cli-darwin-x64@2.0.6': - resolution: {integrity: sha512-wJjjP4E7bO4WJmiQaLnsdXMa516dbtC6542qeRkyJg0MqMXP0fvs4gdsHhZ7p9XWTAmGIjZHFKXdsjBvKGIJJQ==} + '@biomejs/cli-darwin-x64@2.1.0': + resolution: {integrity: sha512-epLFRbMjYS/Cu9Kc5gM3wzUExsKj2Z0oxIiuxlI4ZterIqm19yvTOtJoqSec8gjUXOTNvPVoEIfSSXg37yepow==} engines: {node: '>=14.21.3'} cpu: [x64] os: [darwin] - '@biomejs/cli-linux-arm64-musl@2.0.6': - resolution: {integrity: sha512-CVPEMlin3bW49sBqLBg2x016Pws7eUXA27XYDFlEtponD0luYjg2zQaMJ2nOqlkKG9fqzzkamdYxHdMDc2gZFw==} + '@biomejs/cli-linux-arm64-musl@2.1.0': + resolution: {integrity: sha512-J7z6s/M50wt5lhSkivAs2GJHPhiah3hkdg1LipM6wlK6cVC3YeIA/X6pgWBfjEwyfsFlpc3nRM+pQ17DI8FpDQ==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-arm64@2.0.6': - resolution: {integrity: sha512-ZSVf6TYo5rNMUHIW1tww+rs/krol7U5A1Is/yzWyHVZguuB0lBnIodqyFuwCNqG9aJGyk7xIMS8HG0qGUPz0SA==} + '@biomejs/cli-linux-arm64@2.1.0': + resolution: {integrity: sha512-HZys1/TeIH5lagwtf9yKSO+gtA+cYMJW22ckDGuKt2xIvPu7VqgTNjJtTdRcetXe0+benlMMo+KFs3xL2b/2QA==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-x64-musl@2.0.6': - resolution: {integrity: sha512-mKHE/e954hR/hSnAcJSjkf4xGqZc/53Kh39HVW1EgO5iFi0JutTN07TSjEMg616julRtfSNJi0KNyxvc30Y4rQ==} + '@biomejs/cli-linux-x64-musl@2.1.0': + resolution: {integrity: sha512-uj8felYcBeXh32kznnKrAQoZ9pLqta/6qvwLJ4AZtUmY6cSUUa5c+VLnFtxMfuhvps/M4D55VGnwSINOEblPQg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-linux-x64@2.0.6': - resolution: {integrity: sha512-geM1MkHTV1Kh2Cs/Xzot9BOF3WBacihw6bkEmxkz4nSga8B9/hWy5BDiOG3gHDGIBa8WxT0nzsJs2f/hPqQIQw==} + '@biomejs/cli-linux-x64@2.1.0': + resolution: {integrity: sha512-nAVAP1ov/zcXMhNq3WCbYZmlU/YTF3ZT+LeXR1CEJnDgunPC/Srp7j1LWlrIx6wxNOCDOFow8fmyfC7c/BKLig==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-win32-arm64@2.0.6': - resolution: {integrity: sha512-290V4oSFoKaprKE1zkYVsDfAdn0An5DowZ+GIABgjoq1ndhvNxkJcpxPsiYtT7slbVe3xmlT0ncdfOsN7KruzA==} + '@biomejs/cli-win32-arm64@2.1.0': + resolution: {integrity: sha512-eGGqGs+8Q34n1zp/rEadFRKjzwFszpZ2+p6B1Dmi7dn1DNEYhNXoRWLcjyca+ZSTrdV7COx0scyjgF9Tg73kBw==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [win32] - '@biomejs/cli-win32-x64@2.0.6': - resolution: {integrity: sha512-bfM1Bce0d69Ao7pjTjUS+AWSZ02+5UHdiAP85Th8e9yV5xzw6JrHXbL5YWlcEKQ84FIZMdDc7ncuti1wd2sdbw==} + '@biomejs/cli-win32-x64@2.1.0': + resolution: {integrity: sha512-pkp6jucyvE8DJSXXwSKs+Mxx1KXkMJ2d8GbBu4Lf0nAQHl40TZjjp1RuNEo9Z7NNXPQzbLACDtK6/vDalO2WRg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [win32] @@ -801,63 +801,63 @@ packages: '@types/unist@3.0.3': resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} - '@typescript-eslint/eslint-plugin@8.35.1': - resolution: {integrity: sha512-9XNTlo7P7RJxbVeICaIIIEipqxLKguyh+3UbXuT2XQuFp6d8VOeDEGuz5IiX0dgZo8CiI6aOFLg4e8cF71SFVg==} + '@typescript-eslint/eslint-plugin@8.36.0': + resolution: {integrity: sha512-lZNihHUVB6ZZiPBNgOQGSxUASI7UJWhT8nHyUGCnaQ28XFCw98IfrMCG3rUl1uwUWoAvodJQby2KTs79UTcrAg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^8.35.1 + '@typescript-eslint/parser': ^8.36.0 eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/parser@8.35.1': - resolution: {integrity: sha512-3MyiDfrfLeK06bi/g9DqJxP5pV74LNv4rFTyvGDmT3x2p1yp1lOd+qYZfiRPIOf/oON+WRZR5wxxuF85qOar+w==} + '@typescript-eslint/parser@8.36.0': + resolution: {integrity: sha512-FuYgkHwZLuPbZjQHzJXrtXreJdFMKl16BFYyRrLxDhWr6Qr7Kbcu2s1Yhu8tsiMXw1S0W1pjfFfYEt+R604s+Q==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/project-service@8.35.1': - resolution: {integrity: sha512-VYxn/5LOpVxADAuP3NrnxxHYfzVtQzLKeldIhDhzC8UHaiQvYlXvKuVho1qLduFbJjjy5U5bkGwa3rUGUb1Q6Q==} + '@typescript-eslint/project-service@8.36.0': + resolution: {integrity: sha512-JAhQFIABkWccQYeLMrHadu/fhpzmSQ1F1KXkpzqiVxA/iYI6UnRt2trqXHt1sYEcw1mxLnB9rKMsOxXPxowN/g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/scope-manager@8.35.1': - resolution: {integrity: sha512-s/Bpd4i7ht2934nG+UoSPlYXd08KYz3bmjLEb7Ye1UVob0d1ENiT3lY8bsCmik4RqfSbPw9xJJHbugpPpP5JUg==} + '@typescript-eslint/scope-manager@8.36.0': + resolution: {integrity: sha512-wCnapIKnDkN62fYtTGv2+RY8FlnBYA3tNm0fm91kc2BjPhV2vIjwwozJ7LToaLAyb1ca8BxrS7vT+Pvvf7RvqA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/tsconfig-utils@8.35.1': - resolution: {integrity: sha512-K5/U9VmT9dTHoNowWZpz+/TObS3xqC5h0xAIjXPw+MNcKV9qg6eSatEnmeAwkjHijhACH0/N7bkhKvbt1+DXWQ==} + '@typescript-eslint/tsconfig-utils@8.36.0': + resolution: {integrity: sha512-Nhh3TIEgN18mNbdXpd5Q8mSCBnrZQeY9V7Ca3dqYvNDStNIGRmJA6dmrIPMJ0kow3C7gcQbpsG2rPzy1Ks/AnA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/type-utils@8.35.1': - resolution: {integrity: sha512-HOrUBlfVRz5W2LIKpXzZoy6VTZzMu2n8q9C2V/cFngIC5U1nStJgv0tMV4sZPzdf4wQm9/ToWUFPMN9Vq9VJQQ==} + '@typescript-eslint/type-utils@8.36.0': + resolution: {integrity: sha512-5aaGYG8cVDd6cxfk/ynpYzxBRZJk7w/ymto6uiyUFtdCozQIsQWh7M28/6r57Fwkbweng8qAzoMCPwSJfWlmsg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/types@8.35.1': - resolution: {integrity: sha512-q/O04vVnKHfrrhNAscndAn1tuQhIkwqnaW+eu5waD5IPts2eX1dgJxgqcPx5BX109/qAz7IG6VrEPTOYKCNfRQ==} + '@typescript-eslint/types@8.36.0': + resolution: {integrity: sha512-xGms6l5cTJKQPZOKM75Dl9yBfNdGeLRsIyufewnxT4vZTrjC0ImQT4fj8QmtJK84F58uSh5HVBSANwcfiXxABQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.35.1': - resolution: {integrity: sha512-Vvpuvj4tBxIka7cPs6Y1uvM7gJgdF5Uu9F+mBJBPY4MhvjrjWGK4H0lVgLJd/8PWZ23FTqsaJaLEkBCFUk8Y9g==} + '@typescript-eslint/typescript-estree@8.36.0': + resolution: {integrity: sha512-JaS8bDVrfVJX4av0jLpe4ye0BpAaUW7+tnS4Y4ETa3q7NoZgzYbN9zDQTJ8kPb5fQ4n0hliAt9tA4Pfs2zA2Hg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/utils@8.35.1': - resolution: {integrity: sha512-lhnwatFmOFcazAsUm3ZnZFpXSxiwoa1Lj50HphnDe1Et01NF4+hrdXONSUHIcbVu2eFb1bAf+5yjXkGVkXBKAQ==} + '@typescript-eslint/utils@8.36.0': + resolution: {integrity: sha512-VOqmHu42aEMT+P2qYjylw6zP/3E/HvptRwdn/PZxyV27KhZg2IOszXod4NcXisWzPAGSS4trE/g4moNj6XmH2g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/visitor-keys@8.35.1': - resolution: {integrity: sha512-VRwixir4zBWCSTP/ljEo091lbpypz57PoeAQ9imjG+vbeof9LplljsL1mos4ccG6H9IjfrVGM359RozUnuFhpw==} + '@typescript-eslint/visitor-keys@8.36.0': + resolution: {integrity: sha512-vZrhV2lRPWDuGoxcmrzRZyxAggPL+qp3WzUrlZD+slFueDiYHxeBa34dUXPuC0RmGKzl4lS5kFJYvKCq9cnNDA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@unrs/resolver-binding-android-arm-eabi@1.11.0': @@ -2666,8 +2666,8 @@ packages: peerDependencies: typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x - typescript-eslint@8.35.1: - resolution: {integrity: sha512-xslJjFzhOmHYQzSB/QTeASAHbjmxOGEP6Coh93TXmUBFQoJ1VU35UHIDmG06Jd6taf3wqqC1ntBnCMeymy5Ovw==} + typescript-eslint@8.36.0: + resolution: {integrity: sha512-fTCqxthY+h9QbEgSIBfL9iV6CvKDFuoxg6bHPNpJ9HIUzS+jy2lCEyCmGyZRWEBSaykqcDPf1SJ+BfCI8DRopA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -2809,39 +2809,39 @@ snapshots: '@bcoe/v8-coverage@1.0.2': {} - '@biomejs/biome@2.0.6': + '@biomejs/biome@2.1.0': optionalDependencies: - '@biomejs/cli-darwin-arm64': 2.0.6 - '@biomejs/cli-darwin-x64': 2.0.6 - '@biomejs/cli-linux-arm64': 2.0.6 - '@biomejs/cli-linux-arm64-musl': 2.0.6 - '@biomejs/cli-linux-x64': 2.0.6 - '@biomejs/cli-linux-x64-musl': 2.0.6 - '@biomejs/cli-win32-arm64': 2.0.6 - '@biomejs/cli-win32-x64': 2.0.6 - - '@biomejs/cli-darwin-arm64@2.0.6': + '@biomejs/cli-darwin-arm64': 2.1.0 + '@biomejs/cli-darwin-x64': 2.1.0 + '@biomejs/cli-linux-arm64': 2.1.0 + '@biomejs/cli-linux-arm64-musl': 2.1.0 + '@biomejs/cli-linux-x64': 2.1.0 + '@biomejs/cli-linux-x64-musl': 2.1.0 + '@biomejs/cli-win32-arm64': 2.1.0 + '@biomejs/cli-win32-x64': 2.1.0 + + '@biomejs/cli-darwin-arm64@2.1.0': optional: true - '@biomejs/cli-darwin-x64@2.0.6': + '@biomejs/cli-darwin-x64@2.1.0': optional: true - '@biomejs/cli-linux-arm64-musl@2.0.6': + '@biomejs/cli-linux-arm64-musl@2.1.0': optional: true - '@biomejs/cli-linux-arm64@2.0.6': + '@biomejs/cli-linux-arm64@2.1.0': optional: true - '@biomejs/cli-linux-x64-musl@2.0.6': + '@biomejs/cli-linux-x64-musl@2.1.0': optional: true - '@biomejs/cli-linux-x64@2.0.6': + '@biomejs/cli-linux-x64@2.1.0': optional: true - '@biomejs/cli-win32-arm64@2.0.6': + '@biomejs/cli-win32-arm64@2.1.0': optional: true - '@biomejs/cli-win32-x64@2.0.6': + '@biomejs/cli-win32-x64@2.1.0': optional: true '@commitlint/cli@19.8.1(@types/node@24.0.10)(typescript@5.8.3)': @@ -3188,7 +3188,7 @@ snapshots: '@es-joy/jsdoccomment@0.52.0': dependencies: '@types/estree': 1.0.8 - '@typescript-eslint/types': 8.35.1 + '@typescript-eslint/types': 8.36.0 comment-parser: 1.4.1 esquery: 1.6.0 jsdoc-type-pratt-parser: 4.1.0 @@ -3460,7 +3460,7 @@ snapshots: '@stylistic/eslint-plugin@2.11.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': dependencies: - '@typescript-eslint/utils': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) eslint: 9.30.1(jiti@2.4.2) eslint-visitor-keys: 4.2.1 espree: 10.4.0 @@ -3495,14 +3495,14 @@ snapshots: '@types/unist@3.0.3': {} - '@typescript-eslint/eslint-plugin@8.35.1(@typescript-eslint/parser@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/eslint-plugin@8.36.0(@typescript-eslint/parser@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/scope-manager': 8.35.1 - '@typescript-eslint/type-utils': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/utils': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/visitor-keys': 8.35.1 + '@typescript-eslint/parser': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/scope-manager': 8.36.0 + '@typescript-eslint/type-utils': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.36.0 eslint: 9.30.1(jiti@2.4.2) graphemer: 1.4.0 ignore: 7.0.5 @@ -3512,40 +3512,40 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/parser@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': dependencies: - '@typescript-eslint/scope-manager': 8.35.1 - '@typescript-eslint/types': 8.35.1 - '@typescript-eslint/typescript-estree': 8.35.1(typescript@5.8.3) - '@typescript-eslint/visitor-keys': 8.35.1 + '@typescript-eslint/scope-manager': 8.36.0 + '@typescript-eslint/types': 8.36.0 + '@typescript-eslint/typescript-estree': 8.36.0(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.36.0 debug: 4.4.1(supports-color@8.1.1) eslint: 9.30.1(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.35.1(typescript@5.8.3)': + '@typescript-eslint/project-service@8.36.0(typescript@5.8.3)': dependencies: - '@typescript-eslint/tsconfig-utils': 8.35.1(typescript@5.8.3) - '@typescript-eslint/types': 8.35.1 + '@typescript-eslint/tsconfig-utils': 8.36.0(typescript@5.8.3) + '@typescript-eslint/types': 8.36.0 debug: 4.4.1(supports-color@8.1.1) typescript: 5.8.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.35.1': + '@typescript-eslint/scope-manager@8.36.0': dependencies: - '@typescript-eslint/types': 8.35.1 - '@typescript-eslint/visitor-keys': 8.35.1 + '@typescript-eslint/types': 8.36.0 + '@typescript-eslint/visitor-keys': 8.36.0 - '@typescript-eslint/tsconfig-utils@8.35.1(typescript@5.8.3)': + '@typescript-eslint/tsconfig-utils@8.36.0(typescript@5.8.3)': dependencies: typescript: 5.8.3 - '@typescript-eslint/type-utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/type-utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': dependencies: - '@typescript-eslint/typescript-estree': 8.35.1(typescript@5.8.3) - '@typescript-eslint/utils': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/typescript-estree': 8.36.0(typescript@5.8.3) + '@typescript-eslint/utils': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) debug: 4.4.1(supports-color@8.1.1) eslint: 9.30.1(jiti@2.4.2) ts-api-utils: 2.1.0(typescript@5.8.3) @@ -3553,14 +3553,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/types@8.35.1': {} + '@typescript-eslint/types@8.36.0': {} - '@typescript-eslint/typescript-estree@8.35.1(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@8.36.0(typescript@5.8.3)': dependencies: - '@typescript-eslint/project-service': 8.35.1(typescript@5.8.3) - '@typescript-eslint/tsconfig-utils': 8.35.1(typescript@5.8.3) - '@typescript-eslint/types': 8.35.1 - '@typescript-eslint/visitor-keys': 8.35.1 + '@typescript-eslint/project-service': 8.36.0(typescript@5.8.3) + '@typescript-eslint/tsconfig-utils': 8.36.0(typescript@5.8.3) + '@typescript-eslint/types': 8.36.0 + '@typescript-eslint/visitor-keys': 8.36.0 debug: 4.4.1(supports-color@8.1.1) fast-glob: 3.3.3 is-glob: 4.0.3 @@ -3571,20 +3571,20 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': + '@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3)': dependencies: '@eslint-community/eslint-utils': 4.7.0(eslint@9.30.1(jiti@2.4.2)) - '@typescript-eslint/scope-manager': 8.35.1 - '@typescript-eslint/types': 8.35.1 - '@typescript-eslint/typescript-estree': 8.35.1(typescript@5.8.3) + '@typescript-eslint/scope-manager': 8.36.0 + '@typescript-eslint/types': 8.36.0 + '@typescript-eslint/typescript-estree': 8.36.0(typescript@5.8.3) eslint: 9.30.1(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/visitor-keys@8.35.1': + '@typescript-eslint/visitor-keys@8.36.0': dependencies: - '@typescript-eslint/types': 8.35.1 + '@typescript-eslint/types': 8.36.0 eslint-visitor-keys: 4.2.1 '@unrs/resolver-binding-android-arm-eabi@1.11.0': @@ -4213,7 +4213,7 @@ snapshots: - supports-color optional: true - eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)))(eslint@9.30.1(jiti@2.4.2)): + eslint-import-resolver-typescript@3.10.1(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)))(eslint@9.30.1(jiti@2.4.2)): dependencies: '@nolyfill/is-core-module': 1.0.39 debug: 4.4.1(supports-color@8.1.1) @@ -4224,7 +4224,7 @@ snapshots: tinyglobby: 0.2.14 unrs-resolver: 1.11.0 optionalDependencies: - eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)) + eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)) transitivePeerDependencies: - supports-color @@ -4235,9 +4235,9 @@ snapshots: eslint: 9.30.1(jiti@2.4.2) eslint-compat-utils: 0.5.1(eslint@9.30.1(jiti@2.4.2)) - eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)): + eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)): dependencies: - '@typescript-eslint/types': 8.35.1 + '@typescript-eslint/types': 8.36.0 comment-parser: 1.4.1 debug: 4.4.1(supports-color@8.1.1) eslint: 9.30.1(jiti@2.4.2) @@ -4248,7 +4248,7 @@ snapshots: stable-hash-x: 0.2.0 unrs-resolver: 1.11.0 optionalDependencies: - '@typescript-eslint/utils': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: - supports-color @@ -4286,8 +4286,8 @@ snapshots: eslint-plugin-perfectionist@4.15.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3): dependencies: - '@typescript-eslint/types': 8.35.1 - '@typescript-eslint/utils': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/types': 8.36.0 + '@typescript-eslint/utils': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) eslint: 9.30.1(jiti@2.4.2) natural-orderby: 5.0.0 transitivePeerDependencies: @@ -5033,20 +5033,20 @@ snapshots: natural-orderby@5.0.0: {} - neostandard@0.12.2(@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3): + neostandard@0.12.2(@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3): dependencies: '@humanwhocodes/gitignore-to-minimatch': 1.0.2 '@stylistic/eslint-plugin': 2.11.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) eslint: 9.30.1(jiti@2.4.2) - eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)))(eslint@9.30.1(jiti@2.4.2)) - eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)) + eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)))(eslint@9.30.1(jiti@2.4.2)) + eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint@9.30.1(jiti@2.4.2)) eslint-plugin-n: 17.21.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) eslint-plugin-promise: 7.2.1(eslint@9.30.1(jiti@2.4.2)) eslint-plugin-react: 7.37.5(eslint@9.30.1(jiti@2.4.2)) find-up: 5.0.0 globals: 15.15.0 peowly: 1.3.2 - typescript-eslint: 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + typescript-eslint: 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) transitivePeerDependencies: - '@typescript-eslint/utils' - eslint-import-resolver-node @@ -5630,11 +5630,11 @@ snapshots: typescript: 5.8.3 yaml: 2.8.0 - typescript-eslint@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3): + typescript-eslint@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.35.1(@typescript-eslint/parser@8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/parser': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) - '@typescript-eslint/utils': 8.35.1(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/eslint-plugin': 8.36.0(@typescript-eslint/parser@8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3))(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/parser': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.36.0(eslint@9.30.1(jiti@2.4.2))(typescript@5.8.3) eslint: 9.30.1(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 59aab3978..298bc2a28 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -390,6 +390,11 @@ export abstract class AbstractPool< } } + /** + * Whether the pool is destroying or not. + */ + protected destroying: boolean + /** * The task execution response promise map: * - `key`: The message id of each submitted task. @@ -405,6 +410,16 @@ export abstract class AbstractPool< PromiseResponseWrapper >() + /** + * Whether the pool is started or not. + */ + protected started: boolean + + /** + * Whether the pool is starting or not. + */ + protected starting: boolean + /** * Worker choice strategies context referencing worker choice algorithms implementation. */ @@ -448,26 +463,11 @@ export abstract class AbstractPool< */ private busyEventEmitted: boolean - /** - * Whether the pool is destroying or not. - */ - private destroying: boolean - /** * Whether the pool ready event has been emitted or not. */ private readyEventEmitted: boolean - /** - * Whether the pool is started or not. - */ - private started: boolean - - /** - * Whether the pool is starting or not. - */ - private starting: boolean - /** * Whether the minimum number of workers is starting or not. */ @@ -1331,12 +1331,18 @@ export abstract class AbstractPool< protected readonly workerMessageListener = ( message: MessageValue ): void => { - if (message.kill != null) { + const { kill, ready, taskFunctionsProperties, taskId, workerId } = message + const workerReadyMessage = ready != null && taskFunctionsProperties != null + // Late worker ready message received + if (this.destroying && workerReadyMessage) { + return + } + // Kill messages response are handled in dedicated listeners + if (kill != null) { return } this.checkMessageWorkerId(message) - const { ready, taskFunctionsProperties, taskId, workerId } = message - if (ready != null && taskFunctionsProperties != null) { + if (workerReadyMessage) { // Worker ready response received from worker this.handleWorkerReadyResponse(message) } else if (taskFunctionsProperties != null) { @@ -1355,7 +1361,7 @@ export abstract class AbstractPool< } private readonly abortTask = (eventDetail: WorkerNodeEventDetail): void => { - if (!this.started || this.destroying) { + if (!this.started) { return } const { taskId, workerId } = eventDetail @@ -1419,7 +1425,12 @@ export abstract class AbstractPool< } private cannotStealTask (): boolean { - return this.workerNodes.length <= 1 || this.info.queuedTasks === 0 + return ( + !this.started || + this.destroying || + this.workerNodes.length <= 1 || + this.info.queuedTasks === 0 + ) } private checkAndEmitReadyEvent (): void { @@ -1858,6 +1869,10 @@ export abstract class AbstractPool< const { workerId } = eventDetail const sourceWorkerNode = this.workerNodes[this.getWorkerNodeKeyByWorkerId(workerId)] + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (sourceWorkerNode == null) { + return + } const workerNodes = this.workerNodes .slice() .sort( @@ -2163,19 +2178,31 @@ export abstract class AbstractPool< } } - private async sendKillMessageToWorker (workerNodeKey: number): Promise { + private async sendKillMessageToWorker ( + workerNodeKey: number, + timeout = 2000 + ): Promise { + let timeoutHandle: NodeJS.Timeout | undefined let killMessageListener: | ((message: MessageValue) => void) | undefined try { await new Promise((resolve, reject) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (this.workerNodes[workerNodeKey] == null) { - resolve() - return - } + timeoutHandle = + timeout >= 0 + ? setTimeout(() => { + resolve() + }, timeout) + : undefined killMessageListener = (message: MessageValue): void => { - this.checkMessageWorkerId(message) + if ( + this.workerNodes.length === 0 || + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + this.workerNodes[workerNodeKey] == null + ) { + resolve() + return + } if (message.kill === 'success') { resolve() } else if (message.kill === 'failure') { @@ -2191,6 +2218,9 @@ export abstract class AbstractPool< this.sendToWorker(workerNodeKey, { kill: true }) }) } finally { + if (timeoutHandle != null) { + clearTimeout(timeoutHandle) + } if (killMessageListener != null) { this.deregisterWorkerMessageListener(workerNodeKey, killMessageListener) } @@ -2223,11 +2253,6 @@ export abstract class AbstractPool< | undefined try { return await new Promise((resolve, reject) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (this.workerNodes[workerNodeKey] == null) { - resolve(true) - return - } taskFunctionOperationListener = ( message: MessageValue ): void => { @@ -2310,10 +2335,6 @@ export abstract class AbstractPool< let listener: ((message: MessageValue) => void) | undefined try { return await new Promise((resolve, reject) => { - if (targetWorkerNodeKeys.length === 0) { - resolve(true) - return - } const responsesReceived: MessageValue[] = [] listener = (message: MessageValue) => { taskFunctionOperationsListener( diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index 067ef3b82..1d2900677 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -114,6 +114,10 @@ export class DynamicClusterPool< /** @inheritDoc */ protected override shallCreateDynamicWorker (): boolean { - return (!this.full && this.internalBusy()) || this.empty + return ( + this.started && + !this.destroying && + ((!this.full && this.internalBusy()) || this.empty) + ) } } diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index d70477266..6bfd0783c 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -86,7 +86,7 @@ export class FixedClusterPool< workerNodeKey: number, listener: (message: MessageValue) => void ): void { - this.workerNodes[workerNodeKey].worker.once('message', listener) + this.workerNodes[workerNodeKey]?.worker.once('message', listener) } /** @inheritDoc */ @@ -94,7 +94,7 @@ export class FixedClusterPool< workerNodeKey: number, listener: (message: MessageValue) => void ): void { - this.workerNodes[workerNodeKey].worker.on('message', listener) + this.workerNodes[workerNodeKey]?.worker.on('message', listener) } /** @inheritDoc */ diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index b64f79a60..32beca8e6 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -114,6 +114,10 @@ export class DynamicThreadPool< /** @inheritDoc */ protected override shallCreateDynamicWorker (): boolean { - return (!this.full && this.internalBusy()) || this.empty + return ( + this.started && + !this.destroying && + ((!this.full && this.internalBusy()) || this.empty) + ) } } diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index 5d1ffbaba..bdf63e6a3 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -93,7 +93,7 @@ export class FixedThreadPool< workerNodeKey: number, listener: (message: MessageValue) => void ): void { - this.workerNodes[workerNodeKey].messageChannel?.port1.once( + this.workerNodes[workerNodeKey]?.messageChannel?.port1.once( 'message', listener ) @@ -104,7 +104,7 @@ export class FixedThreadPool< workerNodeKey: number, listener: (message: MessageValue) => void ): void { - this.workerNodes[workerNodeKey].messageChannel?.port1.on( + this.workerNodes[workerNodeKey]?.messageChannel?.port1.on( 'message', listener ) -- 2.53.0