@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.umd.js CHANGED
@@ -49453,6 +49453,7 @@ export default ${safeId}Collection;
49453
49453
  scheduleNext(id) {
49454
49454
  const job = this.jobs.get(id);
49455
49455
  if (!job || !job.enabled || !this.started) return;
49456
+ this.stopJob(id);
49456
49457
  try {
49457
49458
  const now = /* @__PURE__ */ new Date();
49458
49459
  const nextRun = parseCronExpression(job.definition.schedule, now);
@@ -49498,10 +49499,15 @@ export default ${safeId}Collection;
49498
49499
  try {
49499
49500
  const timeout = (job.definition.timeoutSeconds ?? 300) * 1e3;
49500
49501
  const handlerPromise = Promise.resolve(job.definition.handler(ctx));
49502
+ let timeoutHandle;
49501
49503
  const timeoutPromise = new Promise((_, reject) => {
49502
- setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
49504
+ timeoutHandle = setTimeout(() => reject(new Error(`Cron job "${job.id}" timed out after ${timeout}ms`)), timeout);
49503
49505
  });
49504
- result = await Promise.race([handlerPromise, timeoutPromise]);
49506
+ try {
49507
+ result = await Promise.race([handlerPromise, timeoutPromise]);
49508
+ } finally {
49509
+ clearTimeout(timeoutHandle);
49510
+ }
49505
49511
  } catch (err) {
49506
49512
  success = false;
49507
49513
  error2 = err instanceof Error ? err.message : String(err);