From 8ba9c85438f7a9a8a5f3b61dfad6d2a4e7215b50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 11 Feb 2024 17:07:35 +0100 Subject: [PATCH] fix: ensure workers are unreferenced at termination MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- src/worker/WorkerSet.ts | 3 +++ ui/web/pnpm-lock.yaml | 6 +++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 40521799..e2de0727 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "logform": "^2.6.0", "mnemonist": "0.40.0-rc1", "mongodb": "^6.3.0", - "poolifier": "^3.1.19", + "poolifier": "^3.1.20", "tar": "^6.2.0", "winston": "^3.11.0", "winston-daily-rotate-file": "^5.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index be83ed4b..0558941a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ dependencies: specifier: ^6.3.0 version: 6.3.0 poolifier: - specifier: ^3.1.19 - version: 3.1.19 + specifier: ^3.1.20 + version: 3.1.20 tar: specifier: ^6.2.0 version: 6.2.0 @@ -1621,8 +1621,8 @@ packages: resolution: {integrity: sha512-ytDiArvrn/3Xk6/vtylys5tlY6eo7Ane0hvcx++TKo6RxQXuVfW0AF/oeWqAj9dN29SyhtawuXstgmPlwNcv/A==} dev: true - /@types/semver@7.5.6: - resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} + /@types/semver@7.5.7: + resolution: {integrity: sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==} dev: true /@types/stack-utils@2.0.3: @@ -1783,7 +1783,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.56.0) '@types/json-schema': 7.0.15 - '@types/semver': 7.5.6 + '@types/semver': 7.5.7 '@typescript-eslint/scope-manager': 6.21.0 '@typescript-eslint/types': 6.21.0 '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.3.3) @@ -7715,8 +7715,8 @@ packages: semver-compare: 1.0.0 dev: false - /poolifier@3.1.19: - resolution: {integrity: sha512-H/tg/7FNLdZvL0vkJLy2hkjVQWp7QYaDJ0/lJbb4m1ZDtEhOQ4sKsQLlGGI4+jjyWqFlfieqP7FmJC98r4wWyw==} + /poolifier@3.1.20: + resolution: {integrity: sha512-UmT6eHbCwb22J+8cDtcjPJaDc7CMpNaTtJ+7QArTOo6F1DMApXBJny8qGllhwYpAscJT6VoMVoQlN1EHksdQOw==} engines: {node: '>=18.0.0', pnpm: '>=8.6.0'} requiresBuild: true dev: false diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index f10ca9c8..f22f1953 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -92,6 +92,7 @@ export class WorkerSet extends WorkerAbstract { resolve() }) }) + worker.unref() await worker.terminate() await waitWorkerExit } @@ -147,6 +148,8 @@ export class WorkerSet extends WorkerAbstract { ) { this.addWorkerSetElement() } + worker.unref() + worker.terminate().catch(error => this.emitter?.emit(WorkerSetEvents.error, error)) }) worker.on('online', this.workerOptions.poolOptions?.onlineHandler ?? EMPTY_FUNCTION) worker.on('exit', this.workerOptions.poolOptions?.exitHandler ?? EMPTY_FUNCTION) diff --git a/ui/web/pnpm-lock.yaml b/ui/web/pnpm-lock.yaml index 0fc52763..91b94991 100644 --- a/ui/web/pnpm-lock.yaml +++ b/ui/web/pnpm-lock.yaml @@ -900,8 +900,8 @@ packages: undici-types: 5.26.5 dev: true - /@types/semver@7.5.6: - resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} + /@types/semver@7.5.7: + resolution: {integrity: sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==} dev: true /@types/tough-cookie@4.0.5: @@ -1021,7 +1021,7 @@ packages: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.56.0) '@types/json-schema': 7.0.15 - '@types/semver': 7.5.6 + '@types/semver': 7.5.7 '@typescript-eslint/scope-manager': 6.21.0 '@typescript-eslint/types': 6.21.0 '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.3.3) -- 2.34.1