@kumori/aurora-backend-handler 1.1.65 → 1.1.66
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/package.json +1 -1
- package/websocket-manager.ts +24 -1
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -145,6 +145,7 @@ interface Role {
|
|
|
145
145
|
*/
|
|
146
146
|
let wsConnection: WebSocket | null = null;
|
|
147
147
|
let pendingRequests = new Map<string, PendingOperation>();
|
|
148
|
+
let purgingEnvironments = new Set<string>();
|
|
148
149
|
let currentToken: string | null = null;
|
|
149
150
|
let connectionPromise: Promise<WebSocket> | null = null;
|
|
150
151
|
let userData: UserData = {
|
|
@@ -428,6 +429,14 @@ export const makeGlobalWebSocketRequest = async (
|
|
|
428
429
|
payload,
|
|
429
430
|
};
|
|
430
431
|
|
|
432
|
+
let purgeEnvKey: string | null = null;
|
|
433
|
+
if (petitionAction === "CLEAN" && entityType === "environment" && originalData) {
|
|
434
|
+
purgeEnvKey = originalData.tenant && originalData.account
|
|
435
|
+
? `${originalData.tenant}/${originalData.account}/${petitionInfo}`
|
|
436
|
+
: petitionInfo;
|
|
437
|
+
purgingEnvironments.add(purgeEnvKey);
|
|
438
|
+
}
|
|
439
|
+
|
|
431
440
|
return new Promise((resolve, reject) => {
|
|
432
441
|
const timeoutId = setTimeout(() => {
|
|
433
442
|
const pending = pendingRequests.get(messageId);
|
|
@@ -443,6 +452,7 @@ export const makeGlobalWebSocketRequest = async (
|
|
|
443
452
|
new Error(`Request timeout for ${topic}`),
|
|
444
453
|
);
|
|
445
454
|
}
|
|
455
|
+
if (purgeEnvKey) purgingEnvironments.delete(purgeEnvKey);
|
|
446
456
|
const timeoutError = Object.assign(
|
|
447
457
|
new Error(`Request timeout for ${topic}`),
|
|
448
458
|
{ isTimeout: true },
|
|
@@ -453,10 +463,12 @@ export const makeGlobalWebSocketRequest = async (
|
|
|
453
463
|
const operation: PendingOperation = {
|
|
454
464
|
resolve: (response: any) => {
|
|
455
465
|
clearTimeout(timeoutId);
|
|
466
|
+
if (purgeEnvKey) purgingEnvironments.delete(purgeEnvKey);
|
|
456
467
|
resolve(response.payload || response);
|
|
457
468
|
},
|
|
458
469
|
reject: (error: any) => {
|
|
459
470
|
clearTimeout(timeoutId);
|
|
471
|
+
if (purgeEnvKey) purgingEnvironments.delete(purgeEnvKey);
|
|
460
472
|
const errorMessage = safeStringifyError(error);
|
|
461
473
|
console.error(`WebSocket request failed for ${topic}:`, {
|
|
462
474
|
originalError: error,
|
|
@@ -682,7 +694,18 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
682
694
|
);
|
|
683
695
|
}
|
|
684
696
|
const envSetKey = parentParts.tenant && parentParts.account ? `${parentParts.tenant}/${parentParts.account}/${entityId}` : entityId;
|
|
685
|
-
|
|
697
|
+
let envToStore = envEventResult.environment;
|
|
698
|
+
if (envToStore.status?.code === "DELETING" && purgingEnvironments.has(envSetKey)) {
|
|
699
|
+
envToStore = {
|
|
700
|
+
...envToStore,
|
|
701
|
+
status: {
|
|
702
|
+
code: "PURGING",
|
|
703
|
+
message: `Environment ${entityId} is being purged.`,
|
|
704
|
+
timestamp: new Date().toISOString(),
|
|
705
|
+
},
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
environmentsMap.set(envSetKey, envToStore);
|
|
686
709
|
const envTenant = tenantsMap.get(envEventResult.tenantId);
|
|
687
710
|
if (!envTenant) {
|
|
688
711
|
pendingEnvironments.push({
|