Skip to content

Commit f04da46

Browse files
refactor: Change assert.strictEqual to a safe early exit (#844)
Co-authored-by: bryanrideshark <[email protected]>
1 parent 1ea943e commit f04da46

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { resolve } from 'node:path';
44
import { inspect, types } from 'node:util';
55
import { performance } from 'node:perf_hooks';
66
import { setTimeout as sleep } from 'node:timers/promises';
7-
import assert from 'node:assert';
87

98
import { version } from '../package.json';
109
import type {
@@ -444,7 +443,10 @@ class ThreadPool {
444443
if (workerInfo.currentUsage() === 0 &&
445444
this.workers.size > this.options.minThreads) {
446445
workerInfo.idleTimeout = setTimeout(() => {
447-
assert.strictEqual(workerInfo.currentUsage(), 0);
446+
if (workerInfo.currentUsage() !== 0) {
447+
// Exit early - we can't safely remove the worker.
448+
return;
449+
}
448450
if (this.workers.size > this.options.minThreads) {
449451
this._removeWorker(workerInfo);
450452
}

0 commit comments

Comments
 (0)