bulltrackers-module 1.0.209 → 1.0.210
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,10 +2,12 @@
|
|
|
2
2
|
* @fileoverview Main pipe for the Task Engine.
|
|
3
3
|
* REFACTORED: This function is the high-level "manual of processes"
|
|
4
4
|
* that orchestrates the task engine logic.
|
|
5
|
+
* FIXED: Removed dead call to runUsernameLookups.
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
// Import the new utility functions that contain the logic
|
|
8
|
-
|
|
9
|
+
// REMOVED: runUsernameLookups from import
|
|
10
|
+
const { parseTaskPayload, prepareTaskBatches, executeTasks } = require('./utils/task_engine_utils');
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Main pipe: pipe.taskEngine.handleRequest
|
|
@@ -20,15 +22,29 @@ async function handleRequest(message, context, config, dependencies) {
|
|
|
20
22
|
const taskId = `batch-${context.eventId || Date.now()}`;
|
|
21
23
|
try {
|
|
22
24
|
const tasks = parseTaskPayload(message, logger);
|
|
23
|
-
if (!tasks) {return; }
|
|
25
|
+
if (!tasks) { return; }
|
|
26
|
+
|
|
24
27
|
logger.log('INFO', `[TaskEngine/${taskId}] Received batch of ${tasks.length} tasks.`);
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
// Prepare batches
|
|
30
|
+
const { tasksToRun, otherTasks } = await prepareTaskBatches(tasks, batchManager, logger);
|
|
31
|
+
|
|
32
|
+
// REMOVED: await runUsernameLookups(...) which caused the crash
|
|
33
|
+
|
|
34
|
+
// Execute (Now runs everything sequentially inside executeTasks)
|
|
27
35
|
await executeTasks(tasksToRun, otherTasks, dependencies, config, taskId);
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
|
|
37
|
+
} catch (error) {
|
|
38
|
+
logger.log('ERROR', `[TaskEngine/${taskId}] Failed during batch processing.`, { errorMessage: error.message, errorStack: error.stack });
|
|
39
|
+
} finally {
|
|
40
|
+
try {
|
|
41
|
+
logger.log('INFO', `[TaskEngine/${taskId}] Flushing all accumulated batches...`);
|
|
42
|
+
await batchManager.flushBatches();
|
|
43
|
+
logger.log('INFO', `[TaskEngine/${taskId}] Final batch and header flush complete.`);
|
|
44
|
+
} catch (flushError) {
|
|
45
|
+
logger.log('ERROR', `[TaskEngine/${taskId}] Error during final flush attempt.`, { error: flushError.message });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
32
48
|
}
|
|
33
49
|
|
|
34
|
-
module.exports = {handleRequest};
|
|
50
|
+
module.exports = { handleRequest };
|