bulltrackers-module 1.0.743 → 1.0.744
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.
|
@@ -10,16 +10,21 @@
|
|
|
10
10
|
* the Scheduler and the Worker.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
const system = require('../index');
|
|
13
|
+
// REMOVED: const system = require('../index');
|
|
14
|
+
// We will lazy-load this inside the handler to prevent circular dependency cycles.
|
|
14
15
|
|
|
15
16
|
exports.dispatcherHandler = async (req, res) => {
|
|
16
17
|
const startTime = Date.now();
|
|
17
18
|
|
|
18
19
|
try {
|
|
20
|
+
// LAZY LOAD: Require index.js here to ensure it is fully initialized
|
|
21
|
+
// This fixes the "Accessing non-existent property inside circular dependency" error
|
|
22
|
+
const system = require('../index');
|
|
23
|
+
|
|
19
24
|
const {
|
|
20
25
|
computationName,
|
|
21
26
|
targetDate,
|
|
22
|
-
source = 'scheduled', // 'scheduled' | 'on-demand'
|
|
27
|
+
source = 'scheduled', // 'scheduled' | 'on-demand' | 'zombie-recovery'
|
|
23
28
|
entityIds, // Optional: specific entities
|
|
24
29
|
dryRun = false,
|
|
25
30
|
force = false // Optional: run even if hash matches
|
|
@@ -36,6 +41,11 @@ exports.dispatcherHandler = async (req, res) => {
|
|
|
36
41
|
|
|
37
42
|
const date = targetDate || new Date().toISOString().split('T')[0];
|
|
38
43
|
console.log(`[Dispatcher] Received ${source} request: ${computationName} for ${date}`);
|
|
44
|
+
|
|
45
|
+
// Safety check to ensure system is loaded correctly
|
|
46
|
+
if (!system || typeof system.runComputation !== 'function') {
|
|
47
|
+
throw new Error('System not fully initialized (runComputation is missing). Check index.js exports.');
|
|
48
|
+
}
|
|
39
49
|
|
|
40
50
|
// 2. DELEGATE TO ORCHESTRATOR
|
|
41
51
|
// The Orchestrator calls RunAnalyzer internally to check:
|
|
@@ -74,7 +84,7 @@ exports.dispatcherHandler = async (req, res) => {
|
|
|
74
84
|
|
|
75
85
|
// Scheduled tasks need 503 to trigger retry
|
|
76
86
|
// On-demand users need 200 to see the error message immediately
|
|
77
|
-
const httpStatus = source === 'scheduled' ? 503 : 200;
|
|
87
|
+
const httpStatus = source === 'scheduled' || source === 'zombie-recovery' ? 503 : 200;
|
|
78
88
|
|
|
79
89
|
return res.status(httpStatus).json({
|
|
80
90
|
status: result.status,
|