bulltrackers-module 1.0.662 → 1.0.664
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.
|
@@ -53,23 +53,35 @@ function getPackageVersions() {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Publishes a message to trigger the dedicated Build Reporter Cloud Function.
|
|
56
|
+
* Fire-and-forget to avoid blocking initialization.
|
|
56
57
|
*/
|
|
57
58
|
async function requestBuildReport(config, dependencies) {
|
|
58
59
|
const { pubsubUtils, logger } = dependencies;
|
|
59
|
-
const { moduleVersion, calcVersion } = getPackageVersions();
|
|
60
60
|
|
|
61
|
+
// Get versions (synchronous but fast, wrapped in try-catch)
|
|
62
|
+
let moduleVersion = 'unknown';
|
|
63
|
+
let calcVersion = 'unknown';
|
|
61
64
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
calcVersion
|
|
66
|
-
});
|
|
67
|
-
logger.log('INFO', `[BuildReporter] 🛰️ Trigger message sent to ${config.buildReporterTopic}`);
|
|
68
|
-
return { success: true };
|
|
65
|
+
const versions = getPackageVersions();
|
|
66
|
+
moduleVersion = versions.moduleVersion;
|
|
67
|
+
calcVersion = versions.calcVersion;
|
|
69
68
|
} catch (e) {
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
// If version resolution fails, use defaults
|
|
70
|
+
logger.log('WARN', `[BuildReporter] Version resolution failed, using defaults: ${e.message}`);
|
|
72
71
|
}
|
|
72
|
+
|
|
73
|
+
// Fire-and-forget: don't await, just log errors
|
|
74
|
+
pubsubUtils.publish(config.buildReporterTopic, {
|
|
75
|
+
requestedAt: new Date().toISOString(),
|
|
76
|
+
moduleVersion,
|
|
77
|
+
calcVersion
|
|
78
|
+
}).then(() => {
|
|
79
|
+
logger.log('INFO', `[BuildReporter] 🛰️ Trigger message sent to ${config.buildReporterTopic}`);
|
|
80
|
+
}).catch(e => {
|
|
81
|
+
logger.log('ERROR', `[BuildReporter] Failed to publish trigger: ${e.message}`);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return { success: true, status: 'PENDING' };
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
/**
|
|
@@ -42,21 +42,14 @@ class PubSubUtils {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* [NEW] Publishes a single JSON message to a topic.
|
|
45
|
-
* Includes timeout to prevent hanging on network issues.
|
|
46
45
|
*/
|
|
47
|
-
async publish(topicName, message
|
|
46
|
+
async publish(topicName, message) {
|
|
48
47
|
const { pubsub, logger } = this.dependencies;
|
|
49
48
|
const topic = pubsub.topic(topicName);
|
|
50
49
|
const dataBuffer = Buffer.from(JSON.stringify(message));
|
|
51
50
|
|
|
52
51
|
try {
|
|
53
|
-
|
|
54
|
-
const publishPromise = topic.publishMessage({ data: dataBuffer });
|
|
55
|
-
const timeoutPromise = new Promise((_, reject) =>
|
|
56
|
-
setTimeout(() => reject(new Error(`Publish timeout after ${timeoutMs}ms`)), timeoutMs)
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
await Promise.race([publishPromise, timeoutPromise]);
|
|
52
|
+
await topic.publishMessage({ data: dataBuffer });
|
|
60
53
|
} catch (error) {
|
|
61
54
|
logger.log('ERROR', `[Core Utils] Failed to publish message to ${topicName}`, { error: error.message });
|
|
62
55
|
throw error;
|