@sidequest/engine 1.13.4 → 1.13.6
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.
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@sidequest/core');
|
|
4
4
|
var util = require('util');
|
|
5
|
+
require('../job/constants.cjs');
|
|
6
|
+
require('node-cron');
|
|
7
|
+
require('node:util');
|
|
8
|
+
require('node:fs');
|
|
9
|
+
require('node:url');
|
|
10
|
+
require('node:path');
|
|
11
|
+
require('piscina');
|
|
12
|
+
require('../constants.cjs');
|
|
13
|
+
var jobTransitioner = require('../job/job-transitioner.cjs');
|
|
5
14
|
|
|
6
15
|
/**
|
|
7
16
|
* Finds and releases stale jobs, making them available for processing again.
|
|
@@ -16,8 +25,17 @@ async function releaseStaleJobs(backend, maxStaleMs, maxClaimedMs) {
|
|
|
16
25
|
core.logger("Engine").info(`Stale jobs found, making them available to process`);
|
|
17
26
|
core.logger("Engine").debug(`Stale jobs: ${util.inspect(staleJobs)}`);
|
|
18
27
|
for (const jobData of staleJobs) {
|
|
19
|
-
jobData.state
|
|
20
|
-
|
|
28
|
+
if (jobData.state === "running") {
|
|
29
|
+
// We need to use the JobTransitioner to properly handle retries and state transitions
|
|
30
|
+
// This fixes the issue where the release of a stale job incremented the retry count and
|
|
31
|
+
// did not respect the maxRetries setting.
|
|
32
|
+
await jobTransitioner.JobTransitioner.apply(backend, jobData, new core.RetryTransition("Stale job released for retry"));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// If it's "claimed", then the attempt count was not incremented, so we can just set it back to "waiting"
|
|
36
|
+
jobData.state = "waiting";
|
|
37
|
+
await backend.updateJob(jobData);
|
|
38
|
+
}
|
|
21
39
|
}
|
|
22
40
|
}
|
|
23
41
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-stale-jobs.cjs","sources":["../../src/routines/release-stale-jobs.ts"],"sourcesContent":[null],"names":["logger","inspect"],"mappings":"
|
|
1
|
+
{"version":3,"file":"release-stale-jobs.cjs","sources":["../../src/routines/release-stale-jobs.ts"],"sourcesContent":[null],"names":["logger","inspect","JobTransitioner","RetryTransition"],"mappings":";;;;;;;;;;;;;;AAKA;;;;;;AAMG;AACI,eAAe,gBAAgB,CAAC,OAAgB,EAAE,UAAkB,EAAE,YAAoB,EAAA;IAC/F,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;AAEnE,IAAA,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACxBA,WAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA,kDAAA,CAAoD,CAAC;AAC3E,QAAAA,WAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA,YAAA,EAAeC,YAAO,CAAC,SAAS,CAAC,CAAA,CAAE,CAAC;AAC3D,QAAA,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE;AAC/B,YAAA,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE;;;;AAI/B,gBAAA,MAAMC,+BAAe,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,IAAIC,oBAAe,CAAC,8BAA8B,CAAC,CAAC;YACpG;iBAAO;;AAEL,gBAAA,OAAO,CAAC,KAAK,GAAG,SAAS;AACzB,gBAAA,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;YAClC;QACF;IACF;SAAO;QACLH,WAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA,mBAAA,CAAqB,CAAC;IAC/C;AACF;;;;"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { logger } from '@sidequest/core';
|
|
1
|
+
import { logger, RetryTransition } from '@sidequest/core';
|
|
2
2
|
import { inspect } from 'util';
|
|
3
|
+
import '../job/constants.js';
|
|
4
|
+
import 'node-cron';
|
|
5
|
+
import 'node:util';
|
|
6
|
+
import 'node:fs';
|
|
7
|
+
import 'node:url';
|
|
8
|
+
import 'node:path';
|
|
9
|
+
import 'piscina';
|
|
10
|
+
import '../constants.js';
|
|
11
|
+
import { JobTransitioner } from '../job/job-transitioner.js';
|
|
3
12
|
|
|
4
13
|
/**
|
|
5
14
|
* Finds and releases stale jobs, making them available for processing again.
|
|
@@ -14,8 +23,17 @@ async function releaseStaleJobs(backend, maxStaleMs, maxClaimedMs) {
|
|
|
14
23
|
logger("Engine").info(`Stale jobs found, making them available to process`);
|
|
15
24
|
logger("Engine").debug(`Stale jobs: ${inspect(staleJobs)}`);
|
|
16
25
|
for (const jobData of staleJobs) {
|
|
17
|
-
jobData.state
|
|
18
|
-
|
|
26
|
+
if (jobData.state === "running") {
|
|
27
|
+
// We need to use the JobTransitioner to properly handle retries and state transitions
|
|
28
|
+
// This fixes the issue where the release of a stale job incremented the retry count and
|
|
29
|
+
// did not respect the maxRetries setting.
|
|
30
|
+
await JobTransitioner.apply(backend, jobData, new RetryTransition("Stale job released for retry"));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// If it's "claimed", then the attempt count was not incremented, so we can just set it back to "waiting"
|
|
34
|
+
jobData.state = "waiting";
|
|
35
|
+
await backend.updateJob(jobData);
|
|
36
|
+
}
|
|
19
37
|
}
|
|
20
38
|
}
|
|
21
39
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-stale-jobs.js","sources":["../../src/routines/release-stale-jobs.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"release-stale-jobs.js","sources":["../../src/routines/release-stale-jobs.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAKA;;;;;;AAMG;AACI,eAAe,gBAAgB,CAAC,OAAgB,EAAE,UAAkB,EAAE,YAAoB,EAAA;IAC/F,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;AAEnE,IAAA,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACxB,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA,kDAAA,CAAoD,CAAC;AAC3E,QAAA,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA,YAAA,EAAe,OAAO,CAAC,SAAS,CAAC,CAAA,CAAE,CAAC;AAC3D,QAAA,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE;AAC/B,YAAA,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE;;;;AAI/B,gBAAA,MAAM,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,eAAe,CAAC,8BAA8B,CAAC,CAAC;YACpG;iBAAO;;AAEL,gBAAA,OAAO,CAAC,KAAK,GAAG,SAAS;AACzB,gBAAA,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;YAClC;QACF;IACF;SAAO;QACL,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAA,mBAAA,CAAqB,CAAC;IAC/C;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sidequest/engine",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.6",
|
|
4
4
|
"description": "@sidequest/engine is the core engine of SideQuest, a distributed background job processing system for Node.js and TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nodejs",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
},
|
|
43
43
|
"license": "LGPL-3.0-or-later",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@sidequest/backend": "1.13.
|
|
46
|
-
"@sidequest/core": "1.13.
|
|
45
|
+
"@sidequest/backend": "1.13.6",
|
|
46
|
+
"@sidequest/core": "1.13.6",
|
|
47
47
|
"node-cron": "^4.2.1",
|
|
48
48
|
"piscina": "^5.1.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"sidequest": "1.13.
|
|
51
|
+
"sidequest": "1.13.6"
|
|
52
52
|
}
|
|
53
53
|
}
|