@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.js CHANGED
@@ -2617,7 +2617,7 @@ var TaskStopRunner = class extends AbstractTask {
2617
2617
  */
2618
2618
  static async resolveCustomParams(context, overrides = {}) {
2619
2619
  const merged = AbstractTask._mergeTypedParams(context, "task-stop", {
2620
- allowanceMs: "number default 5000"
2620
+ allowanceMs: "number default 60000"
2621
2621
  }, overrides);
2622
2622
  const allowanceMs = Number(merged.allowanceMs);
2623
2623
  if (!Number.isFinite(allowanceMs) || allowanceMs < 0) {
@@ -2631,7 +2631,7 @@ var TaskStopRunner = class extends AbstractTask {
2631
2631
  * @returns {Promise<{ success: true, results: { stopRunner: true, allowanceMs: number, message: string } }>}
2632
2632
  */
2633
2633
  async run() {
2634
- const allowanceMs = Number(this.task?.params?.allowanceMs ?? 5e3);
2634
+ const allowanceMs = Number(this.task?.params?.allowanceMs ?? 6e4);
2635
2635
  this.context.logger.warn?.(`[TaskStopRunner] stop requested (allowanceMs=${allowanceMs})`);
2636
2636
  return {
2637
2637
  success: true,
@@ -3316,7 +3316,7 @@ function normalizeRegistry(registry) {
3316
3316
  if (registry instanceof TasksRegistry) return registry;
3317
3317
  return new TasksRegistry().addMany(registry);
3318
3318
  }
3319
- async function enqueueStopTask(context, serviceGroup, queueName = "tasks", allowanceMs = 5e3) {
3319
+ async function enqueueStopTask(context, serviceGroup, queueName = "tasks", allowanceMs = 6e4) {
3320
3320
  return enqueueTask(context, {
3321
3321
  queueName,
3322
3322
  name: "stopRunner",
@@ -3455,7 +3455,7 @@ async function executeClaimedTask(context, tasksTable, historyTable, row, regist
3455
3455
  await db(tasksTable).where({ id: row.id }).delete();
3456
3456
  }
3457
3457
  const stopRunnerRequested = !!(results && typeof results === "object" && results.stopRunner === true);
3458
- const stopAllowanceMs = stopRunnerRequested ? Number(results.allowanceMs ?? 5e3) : 0;
3458
+ const stopAllowanceMs = stopRunnerRequested ? Number(results.allowanceMs ?? 6e4) : 0;
3459
3459
  return { stopRunnerRequested, stopAllowanceMs };
3460
3460
  }
3461
3461
  function shuffleTaskRowsInPlace(rows) {
@@ -3545,7 +3545,7 @@ async function runTasksLoop(context, options) {
3545
3545
  const runningTaskInstances = /* @__PURE__ */ new Map();
3546
3546
  let runningControlPromise = null;
3547
3547
  let stopRequested = false;
3548
- let stopAllowanceMs = 5e3;
3548
+ let stopAllowanceMs = Number(context.stopAllowanceMs) > 0 ? Number(context.stopAllowanceMs) : 6e4;
3549
3549
  context.tasksRunnerStop = false;
3550
3550
  let registryReg = null;
3551
3551
  let registryInterval = null;
@@ -3612,7 +3612,7 @@ async function runTasksLoop(context, options) {
3612
3612
  ).then(async (outcome) => {
3613
3613
  if (outcome.stopRunnerRequested && !stopRequested) {
3614
3614
  stopRequested = true;
3615
- stopAllowanceMs = outcome.stopAllowanceMs || 5e3;
3615
+ stopAllowanceMs = outcome.stopAllowanceMs || stopAllowanceMs;
3616
3616
  context.tasksRunnerStop = true;
3617
3617
  await signalRunningTasksStop(context, runningTaskInstances, stopAllowanceMs);
3618
3618
  }
@@ -3638,7 +3638,7 @@ async function runTasksLoop(context, options) {
3638
3638
  const p = executeClaimedTask(context, tasksTable, historyTable, claimed, registry, runningTaskInstances).then(async (outcome) => {
3639
3639
  if (outcome.stopRunnerRequested && !stopRequested) {
3640
3640
  stopRequested = true;
3641
- stopAllowanceMs = outcome.stopAllowanceMs || 5e3;
3641
+ stopAllowanceMs = outcome.stopAllowanceMs || stopAllowanceMs;
3642
3642
  context.tasksRunnerStop = true;
3643
3643
  await signalRunningTasksStop(context, runningTaskInstances, stopAllowanceMs);
3644
3644
  }
@@ -3659,7 +3659,9 @@ async function runTasksLoop(context, options) {
3659
3659
  }
3660
3660
  }
3661
3661
  if (context.isStop() && !stopRequested) {
3662
- await signalRunningTasksStop(context, runningTaskInstances, 5e3);
3662
+ stopRequested = true;
3663
+ stopAllowanceMs = Number(context.stopAllowanceMs) > 0 ? Number(context.stopAllowanceMs) : stopAllowanceMs;
3664
+ await signalRunningTasksStop(context, runningTaskInstances, stopAllowanceMs);
3663
3665
  }
3664
3666
  if (runningPromises.size > 0) {
3665
3667
  if (stopRequested) {