@stonyx/cron 0.2.1-alpha.26 → 0.2.1-alpha.28
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/service.js +24 -6
- package/package.json +1 -1
package/dist/service.js
CHANGED
|
@@ -312,13 +312,31 @@ export default class CronService {
|
|
|
312
312
|
// caught too. Deliberately synchronous with the `onJobDue` call below -
|
|
313
313
|
// nothing can interleave between this check and the invocation.
|
|
314
314
|
//
|
|
315
|
-
//
|
|
316
|
-
//
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
|
|
315
|
+
// This is the ONE early return in the phase-2/3 control flow that happens
|
|
316
|
+
// after a claim, so it is the one that has to release the claim by hand.
|
|
317
|
+
// (`executeJob`'s refusal return at the call site is pre-claim; `onTimer`'s
|
|
318
|
+
// re-entrancy return never claims; every return inside `settleJob` is
|
|
319
|
+
// already past phase 3.)
|
|
320
|
+
//
|
|
321
|
+
// Skipping settle entirely here is right - re-inserting or run-logging a
|
|
322
|
+
// removed job is exactly the resurrection `#settleJob`'s identity guard
|
|
323
|
+
// refuses, and its heap entry is already gone. But the claim itself must
|
|
324
|
+
// still come off, because the detached object is NOT unreachable: it is the
|
|
325
|
+
// object `add()` returned and `get()`/`list()` hand out, and
|
|
326
|
+
// `start(initialJobs)` re-registers those objects verbatim, `state`
|
|
327
|
+
// included. Leaving `runningAtMs` set means a consumer that persists jobs
|
|
328
|
+
// rehydrates a permanently dead one - `isDue` false forever, `run()`
|
|
329
|
+
// refused forever, `status()` reporting it healthy. That is the
|
|
330
|
+
// claim-without-settle hazard the try/finally below exists for, reached
|
|
331
|
+
// through a different door.
|
|
332
|
+
//
|
|
333
|
+
// Assigned directly rather than via `applyResult`: this must release the
|
|
334
|
+
// claim and nothing else. No run-log row, no heap entry, no lastStatus, no
|
|
335
|
+
// recomputed nextRunAtMs - the job did not run.
|
|
336
|
+
if (this.jobs.get(job.id) !== job) {
|
|
337
|
+
job.state.runningAtMs = undefined;
|
|
321
338
|
return { status: 'skipped', reason: 'removed' };
|
|
339
|
+
}
|
|
322
340
|
const startMs = Date.now();
|
|
323
341
|
let status = 'ok';
|
|
324
342
|
let error;
|