@kumori/aurora-backend-handler 1.0.65 → 1.0.67

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.
@@ -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
- updatedService.error = {
264
- code: eventData.status.error.code,
265
- message: eventData.status.error.message,
266
- timestamp: eventData.status.error.timestamp || incomingStatus.timestamp,
267
- };
268
- deploymentErrorEvent = updatedService;
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
- const incomingErrorTs = getTimestamp(eventData.status.error.timestamp);
274
- const currentErrorTs = getTimestamp(existingService.error?.timestamp);
275
- if (incomingErrorTs > currentErrorTs) {
276
- updatedService.error = {
277
- code: eventData.status.error.code,
278
- message: eventData.status.error.message,
279
- timestamp: eventData.status.error.timestamp,
280
- };
281
- deploymentErrorEvent = updatedService;
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
- const incomingRevisionId = Number(entityId);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumori/aurora-backend-handler",
3
- "version": "1.0.65",
3
+ "version": "1.0.67",
4
4
  "description": "backend handler",
5
5
  "main": "backend-handler.ts",
6
6
  "scripts": {
@@ -744,14 +744,14 @@ const handleEvent = async (message: WSMessage) => {
744
744
 
745
745
  const savedService = servicesMap.get(serviceResult.serviceFullKey)!;
746
746
  if (savedService.error && savedService.currentRevision) {
747
- const currentRev = savedService.revisions.find(
748
- (rev) => String(rev.id) === String(savedService.currentRevision),
749
- );
750
- if (currentRev && !currentRev.errorCode) {
747
+ const currentRevId = Number(savedService.currentRevision);
748
+ const errorTs = Number(savedService.error.timestamp ?? 0);
749
+ if (currentRevId > errorTs) {
751
750
  savedService.error = undefined;
752
751
  servicesMap.set(serviceResult.serviceFullKey, savedService);
753
752
  }
754
753
  }
754
+
755
755
  const projectLabel = eventData.meta?.labels?.project;
756
756
  if (projectLabel) {
757
757
  const tenant = tenantsMap.get(parentParts.tenant);