@kumori/aurora-backend-handler 1.0.66 → 1.0.68
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/helpers/revision-helper.ts +23 -17
- package/package.json +1 -1
- package/websocket-manager.ts +19 -0
|
@@ -256,33 +256,39 @@ const updateServiceWithRevision = (
|
|
|
256
256
|
const incomingStatus = eventData.status.state;
|
|
257
257
|
const incomingTs = getTimestamp(incomingStatus.timestamp);
|
|
258
258
|
const currentTs = getTimestamp(existingService.status?.timestamp);
|
|
259
|
+
const incomingRevisionId = Number(entityId);
|
|
260
|
+
const currentRevisionId = Number(existingService.currentRevision ?? 0);
|
|
259
261
|
|
|
260
262
|
if (incomingTs > currentTs) {
|
|
261
263
|
updatedService.status = incomingStatus;
|
|
262
264
|
if (eventData.status.error) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
if (incomingRevisionId >= currentRevisionId) {
|
|
266
|
+
updatedService.error = {
|
|
267
|
+
code: eventData.status.error.code,
|
|
268
|
+
message: eventData.status.error.message,
|
|
269
|
+
timestamp:
|
|
270
|
+
eventData.status.error.timestamp || incomingStatus.timestamp,
|
|
271
|
+
};
|
|
272
|
+
deploymentErrorEvent = updatedService;
|
|
273
|
+
}
|
|
269
274
|
} else {
|
|
270
275
|
updatedService.error = undefined;
|
|
271
276
|
}
|
|
272
277
|
} else if (eventData.status.error) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
if (incomingRevisionId >= currentRevisionId) {
|
|
279
|
+
const incomingErrorTs = getTimestamp(eventData.status.error.timestamp);
|
|
280
|
+
const currentErrorTs = getTimestamp(existingService.error?.timestamp);
|
|
281
|
+
if (incomingErrorTs > currentErrorTs) {
|
|
282
|
+
updatedService.error = {
|
|
283
|
+
code: eventData.status.error.code,
|
|
284
|
+
message: eventData.status.error.message,
|
|
285
|
+
timestamp: eventData.status.error.timestamp,
|
|
286
|
+
};
|
|
287
|
+
deploymentErrorEvent = updatedService;
|
|
288
|
+
}
|
|
282
289
|
}
|
|
283
290
|
}
|
|
284
|
-
|
|
285
|
-
const currentRevisionId = Number(existingService.currentRevision ?? 0);
|
|
291
|
+
|
|
286
292
|
if (incomingRevisionId >= currentRevisionId && !eventData.status.error) {
|
|
287
293
|
updatedService.error = undefined;
|
|
288
294
|
}
|
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -75,6 +75,7 @@ import {
|
|
|
75
75
|
import { handleLinkEvent } from "./helpers/link-helper";
|
|
76
76
|
import { eventHelper } from "./backend-handler";
|
|
77
77
|
import { Revision } from "@kumori/aurora-interfaces/interfaces/revision-interface";
|
|
78
|
+
import { requestRevisionData } from "./api/service-api-service";
|
|
78
79
|
|
|
79
80
|
let WebSocketClass: any;
|
|
80
81
|
|
|
@@ -189,6 +190,7 @@ let isLoadingReporting = false;
|
|
|
189
190
|
const REPORTING_ITERATIONS = 5;
|
|
190
191
|
const REPORTING_INTERVAL = 1000;
|
|
191
192
|
let hasLoadedReportingOnce = false;
|
|
193
|
+
let recentlyUpdatedServices = new Map<string, Service>();
|
|
192
194
|
|
|
193
195
|
/**
|
|
194
196
|
* Helper function to safely stringify error objects
|
|
@@ -723,6 +725,17 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
723
725
|
});
|
|
724
726
|
});
|
|
725
727
|
}
|
|
728
|
+
const revisionState = eventData.status?.state?.code;
|
|
729
|
+
if (revisionState === "DEPLOYED" && currentToken) {
|
|
730
|
+
recentlyUpdatedServices.forEach((service, serviceKey) => {
|
|
731
|
+
requestRevisionData(service, currentToken!).catch((err) => {
|
|
732
|
+
console.error(
|
|
733
|
+
`[ws] Error fetching revision data after DEPLOYED for ${serviceKey}:`,
|
|
734
|
+
err,
|
|
735
|
+
);
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
}
|
|
726
739
|
break;
|
|
727
740
|
case "service":
|
|
728
741
|
const serviceResult = handleServiceEvent({
|
|
@@ -751,6 +764,7 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
751
764
|
servicesMap.set(serviceResult.serviceFullKey, savedService);
|
|
752
765
|
}
|
|
753
766
|
}
|
|
767
|
+
|
|
754
768
|
const projectLabel = eventData.meta?.labels?.project;
|
|
755
769
|
if (projectLabel) {
|
|
756
770
|
const tenant = tenantsMap.get(parentParts.tenant);
|
|
@@ -1246,6 +1260,7 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1246
1260
|
}
|
|
1247
1261
|
|
|
1248
1262
|
servicesMap.set(svcSuccessResult.serviceId, updatedService);
|
|
1263
|
+
recentlyUpdatedServices.delete(svcSuccessResult.serviceId);
|
|
1249
1264
|
|
|
1250
1265
|
if (updatedService.role && updatedService.role.length > 0) {
|
|
1251
1266
|
roleMap.set(svcSuccessResult.serviceId, updatedService.role);
|
|
@@ -1284,6 +1299,10 @@ const handleOperationSuccess = (operation: PendingOperation, response: any) => {
|
|
|
1284
1299
|
eventHelper.service.publish.deployed(svcSuccessResult.updatedService);
|
|
1285
1300
|
} else if (svcSuccessResult.eventType === "updated") {
|
|
1286
1301
|
eventHelper.service.publish.updated(svcSuccessResult.updatedService);
|
|
1302
|
+
recentlyUpdatedServices.set(
|
|
1303
|
+
svcSuccessResult.serviceId,
|
|
1304
|
+
svcSuccessResult.updatedService,
|
|
1305
|
+
);
|
|
1287
1306
|
} else if (svcSuccessResult.eventType === "deleting") {
|
|
1288
1307
|
eventHelper.service.publish.updated(svcSuccessResult.updatedService);
|
|
1289
1308
|
}
|