@nmakarov/cli-toolkit 0.50.0 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tasks.cjs CHANGED
@@ -2702,7 +2702,7 @@ var TaskStopRunner = class extends AbstractTask {
2702
2702
  */
2703
2703
  static async resolveCustomParams(context, overrides = {}) {
2704
2704
  const merged = AbstractTask._mergeTypedParams(context, "task-stop", {
2705
- allowanceMs: "number default 5000"
2705
+ allowanceMs: "number default 60000"
2706
2706
  }, overrides);
2707
2707
  const allowanceMs = Number(merged.allowanceMs);
2708
2708
  if (!Number.isFinite(allowanceMs) || allowanceMs < 0) {
@@ -2716,7 +2716,7 @@ var TaskStopRunner = class extends AbstractTask {
2716
2716
  * @returns {Promise<{ success: true, results: { stopRunner: true, allowanceMs: number, message: string } }>}
2717
2717
  */
2718
2718
  async run() {
2719
- const allowanceMs = Number(this.task?.params?.allowanceMs ?? 5e3);
2719
+ const allowanceMs = Number(this.task?.params?.allowanceMs ?? 6e4);
2720
2720
  this.context.logger.warn?.(`[TaskStopRunner] stop requested (allowanceMs=${allowanceMs})`);
2721
2721
  return {
2722
2722
  success: true,
@@ -3401,7 +3401,7 @@ function normalizeRegistry(registry) {
3401
3401
  if (registry instanceof TasksRegistry) return registry;
3402
3402
  return new TasksRegistry().addMany(registry);
3403
3403
  }
3404
- async function enqueueStopTask(context, serviceGroup, queueName = "tasks", allowanceMs = 5e3) {
3404
+ async function enqueueStopTask(context, serviceGroup, queueName = "tasks", allowanceMs = 6e4) {
3405
3405
  return enqueueTask(context, {
3406
3406
  queueName,
3407
3407
  name: "stopRunner",
@@ -3540,7 +3540,7 @@ async function executeClaimedTask(context, tasksTable, historyTable, row, regist
3540
3540
  await db(tasksTable).where({ id: row.id }).delete();
3541
3541
  }
3542
3542
  const stopRunnerRequested = !!(results && typeof results === "object" && results.stopRunner === true);
3543
- const stopAllowanceMs = stopRunnerRequested ? Number(results.allowanceMs ?? 5e3) : 0;
3543
+ const stopAllowanceMs = stopRunnerRequested ? Number(results.allowanceMs ?? 6e4) : 0;
3544
3544
  return { stopRunnerRequested, stopAllowanceMs };
3545
3545
  }
3546
3546
  function shuffleTaskRowsInPlace(rows) {
@@ -3630,7 +3630,7 @@ async function runTasksLoop(context, options) {
3630
3630
  const runningTaskInstances = /* @__PURE__ */ new Map();
3631
3631
  let runningControlPromise = null;
3632
3632
  let stopRequested = false;
3633
- let stopAllowanceMs = 5e3;
3633
+ let stopAllowanceMs = Number(context.stopAllowanceMs) > 0 ? Number(context.stopAllowanceMs) : 6e4;
3634
3634
  context.tasksRunnerStop = false;
3635
3635
  let registryReg = null;
3636
3636
  let registryInterval = null;
@@ -3697,7 +3697,7 @@ async function runTasksLoop(context, options) {
3697
3697
  ).then(async (outcome) => {
3698
3698
  if (outcome.stopRunnerRequested && !stopRequested) {
3699
3699
  stopRequested = true;
3700
- stopAllowanceMs = outcome.stopAllowanceMs || 5e3;
3700
+ stopAllowanceMs = outcome.stopAllowanceMs || stopAllowanceMs;
3701
3701
  context.tasksRunnerStop = true;
3702
3702
  await signalRunningTasksStop(context, runningTaskInstances, stopAllowanceMs);
3703
3703
  }
@@ -3723,7 +3723,7 @@ async function runTasksLoop(context, options) {
3723
3723
  const p = executeClaimedTask(context, tasksTable, historyTable, claimed, registry, runningTaskInstances).then(async (outcome) => {
3724
3724
  if (outcome.stopRunnerRequested && !stopRequested) {
3725
3725
  stopRequested = true;
3726
- stopAllowanceMs = outcome.stopAllowanceMs || 5e3;
3726
+ stopAllowanceMs = outcome.stopAllowanceMs || stopAllowanceMs;
3727
3727
  context.tasksRunnerStop = true;
3728
3728
  await signalRunningTasksStop(context, runningTaskInstances, stopAllowanceMs);
3729
3729
  }
@@ -3744,7 +3744,9 @@ async function runTasksLoop(context, options) {
3744
3744
  }
3745
3745
  }
3746
3746
  if (context.isStop() && !stopRequested) {
3747
- await signalRunningTasksStop(context, runningTaskInstances, 5e3);
3747
+ stopRequested = true;
3748
+ stopAllowanceMs = Number(context.stopAllowanceMs) > 0 ? Number(context.stopAllowanceMs) : stopAllowanceMs;
3749
+ await signalRunningTasksStop(context, runningTaskInstances, stopAllowanceMs);
3748
3750
  }
3749
3751
  if (runningPromises.size > 0) {
3750
3752
  if (stopRequested) {