@rebasepro/server-core 0.0.1-canary.ca2cb6e → 0.0.1-canary.dbf160a

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/index.es.js CHANGED
@@ -49419,6 +49419,7 @@ class CronScheduler {
49419
49419
  scheduleNext(id) {
49420
49420
  const job = this.jobs.get(id);
49421
49421
  if (!job || !job.enabled || !this.started) return;
49422
+ this.stopJob(id);
49422
49423
  try {
49423
49424
  const now = /* @__PURE__ */ new Date();
49424
49425
  const nextRun = parseCronExpression(job.definition.schedule, now);
@@ -49464,10 +49465,15 @@ class CronScheduler {
49464
49465
  try {
49465
49466
  const timeout = (job.definition.timeoutSeconds ?? 300) * 1e3;
49466
49467
  const handlerPromise = Promise.resolve(job.definition.handler(ctx));
49468
+ let timeoutHandle;
49467
49469
  const timeoutPromise = new Promise((_, reject) => {
49468
- setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
49470
+ timeoutHandle = setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
49469
49471
  });
49470
- result = await Promise.race([handlerPromise, timeoutPromise]);
49472
+ try {
49473
+ result = await Promise.race([handlerPromise, timeoutPromise]);
49474
+ } finally {
49475
+ clearTimeout(timeoutHandle);
49476
+ }
49471
49477
  } catch (err) {
49472
49478
  success = false;
49473
49479
  error2 = err instanceof Error ? err.message : String(err);