Skip to content

Commit 128f52e

Browse files
committed
Graceful shutdown should not complete if forceful shutdown has begun
1 parent 13740a4 commit 128f52e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ export function _runTaskList(
817817
}
818818
}
819819
}
820-
if (jobsToRelease.length > 0) {
820+
if (!this._forcefulShuttingDown && jobsToRelease.length > 0) {
821821
const workerIds = workers.map((worker) => worker.workerId);
822822
logger.debug(
823823
`Releasing the jobs ${jobsToRelease
@@ -839,7 +839,16 @@ export function _runTaskList(
839839
cancelledJobs,
840840
});
841841
}
842-
if (errors.length > 0) {
842+
if (this._forcefulShuttingDown) {
843+
errors.push(
844+
new Error(
845+
"forcefulShutdown was initiated whilst gracefulShutdown was still executing.",
846+
),
847+
);
848+
}
849+
if (errors.length === 1) {
850+
throw errors[0];
851+
} else if (errors.length > 1) {
843852
throw new AggregateError(
844853
errors,
845854
"Errors occurred whilst shutting down worker",

0 commit comments

Comments
 (0)