From: Jérôme Benoit Date: Fri, 18 Aug 2023 14:32:29 +0000 (+0200) Subject: fix: fix error message after worker choice strategies failure X-Git-Tag: v2.6.29~15 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4ba8492f17b13668853cfc15a1ec9ff8c8d7b179;p=poolifier.git fix: fix error message after worker choice strategies failure Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/selection-strategies/worker-choice-strategy-context.ts b/src/pools/selection-strategies/worker-choice-strategy-context.ts index 8c5a9587..fefc1275 100644 --- a/src/pools/selection-strategies/worker-choice-strategy-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategy-context.ts @@ -183,7 +183,9 @@ export class WorkerChoiceStrategyContext< this.choiceRetriesCount++ return this.execute() } else if (workerNodeKey == null) { - throw new TypeError('Worker node key chosen is null or undefined') + throw new TypeError( + `Worker node key chosen is null or undefined after ${this.choiceRetriesCount} retries` + ) } return workerNodeKey } diff --git a/tests/pools/selection-strategies/worker-choice-strategy-context.test.js b/tests/pools/selection-strategies/worker-choice-strategy-context.test.js index 808a44cb..63e58d57 100644 --- a/tests/pools/selection-strategies/worker-choice-strategy-context.test.js +++ b/tests/pools/selection-strategies/worker-choice-strategy-context.test.js @@ -91,7 +91,7 @@ describe('Worker choice strategy context test suite', () => { expect(chosenWorkerKey).toBe(0) }) - it('Verify that execute() throws error if null or undefined is returned', () => { + it('Verify that execute() throws error if null or undefined is returned after retries', () => { const workerChoiceStrategyContext = new WorkerChoiceStrategyContext( fixedPool ) @@ -115,14 +115,18 @@ describe('Worker choice strategy context test suite', () => { WorkerChoiceStrategyUndefinedStub ) expect(() => workerChoiceStrategyContext.execute()).toThrowError( - new TypeError('Worker node key chosen is null or undefined') + new TypeError( + 'Worker node key chosen is null or undefined after 6 retries' + ) ) workerChoiceStrategyContext.workerChoiceStrategies.set( workerChoiceStrategyContext.workerChoiceStrategy, WorkerChoiceStrategyNullStub ) expect(() => workerChoiceStrategyContext.execute()).toThrowError( - new TypeError('Worker node key chosen is null or undefined') + new TypeError( + 'Worker node key chosen is null or undefined after 6 retries' + ) ) })