Skip to content

Commit

Permalink
Add to graceful shutdown errors
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Dec 9, 2024
1 parent 3a0161c commit 31fc5c1
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,26 +845,30 @@ export function _runTaskList(
}
}
if (!this._forcefulShuttingDown && jobsToRelease.length > 0) {
const workerIds = workers.map((worker) => worker.workerId);
logger.debug(
`Releasing the jobs ${jobsToRelease
.map((j) => j.id)
.join()} (workers: ${workerIds.join(", ")})`,
{
jobs: jobsToRelease,
workerIds,
},
);
const cancelledJobs = await failJobs(
compiledSharedOptions,
withPgClient,
workerPool.id,
jobsToRelease,
message,
);
logger.debug(`Cancelled ${cancelledJobs.length} jobs`, {
cancelledJobs,
});
try {
const workerIds = workers.map((worker) => worker.workerId);
logger.debug(
`Releasing the jobs ${jobsToRelease
.map((j) => j.id)
.join()} (workers: ${workerIds.join(", ")})`,
{
jobs: jobsToRelease,
workerIds,
},
);
const cancelledJobs = await failJobs(
compiledSharedOptions,
withPgClient,
workerPool.id,
jobsToRelease,
message,
);
logger.debug(`Cancelled ${cancelledJobs.length} jobs`, {
cancelledJobs,
});
} catch (e) {
gracefulShutdownErrors.push(coerceError(e));
}
}

if (this._forcefulShuttingDown) {
Expand Down

0 comments on commit 31fc5c1

Please sign in to comment.