@dudousxd/nestjs-durable-core 0.85.1 → 0.85.2

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.d.cts CHANGED
@@ -7102,7 +7102,11 @@ declare function scheduleRunIdAt(s: ScheduledWorkflow, nowMs: number): string;
7102
7102
  * Start each schedule's current-window run. The run id is the time bucket (a fixed-interval index,
7103
7103
  * or the cron fire time) and `engine.start` is idempotent, so firing this on an interval — or
7104
7104
  * racing two instances on the same tick — starts **each window exactly once**. Wire it to a
7105
- * `setInterval`, the durable timer poller, or `@nestjs/schedule`. Returns the run ids this call
7105
+ * `setInterval`, the durable timer poller, or `@nestjs/schedule`.
7106
+ *
7107
+ * Pass the SAME `engine` object on every call: which windows already fired, and the jittered fire
7108
+ * time of each deferred window, are remembered per engine object. A fresh wrapper per call would
7109
+ * redraw a deferred window's fire time on every tick, so it might never fire. Returns the run ids this call
7106
7110
  * started: a window that already has a run is not started or returned again, and once this process
7107
7111
  * has seen a window's run exist, later calls in that window skip it without a store read. A
7108
7112
  * jittered window is deferred to a later call, never slept on.
package/dist/index.d.ts CHANGED
@@ -7102,7 +7102,11 @@ declare function scheduleRunIdAt(s: ScheduledWorkflow, nowMs: number): string;
7102
7102
  * Start each schedule's current-window run. The run id is the time bucket (a fixed-interval index,
7103
7103
  * or the cron fire time) and `engine.start` is idempotent, so firing this on an interval — or
7104
7104
  * racing two instances on the same tick — starts **each window exactly once**. Wire it to a
7105
- * `setInterval`, the durable timer poller, or `@nestjs/schedule`. Returns the run ids this call
7105
+ * `setInterval`, the durable timer poller, or `@nestjs/schedule`.
7106
+ *
7107
+ * Pass the SAME `engine` object on every call: which windows already fired, and the jittered fire
7108
+ * time of each deferred window, are remembered per engine object. A fresh wrapper per call would
7109
+ * redraw a deferred window's fire time on every tick, so it might never fire. Returns the run ids this call
7106
7110
  * started: a window that already has a run is not started or returned again, and once this process
7107
7111
  * has seen a window's run exist, later calls in that window skip it without a store read. A
7108
7112
  * jittered window is deferred to a later call, never slept on.
package/dist/index.js CHANGED
@@ -2532,6 +2532,7 @@ async function runSchedules(engine, schedules, nowMs, opts) {
2532
2532
  if (prev && (prev.status === "running" || prev.status === "suspended")) continue;
2533
2533
  }
2534
2534
  }
2535
+ if (!(s.jitter && s.jitter > 0)) jitterFireAt.get(engine)?.delete(s.key);
2535
2536
  const firing = s.jitter && s.jitter > 0 ? jitterDue(engine, s, candidates, nowMs, random) : candidates;
2536
2537
  if (firing.length === 0) continue;
2537
2538
  for (const runId of firing) {