@kumori/aurora-backend-handler 1.1.64 → 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/api/account-api-service.ts +7 -0
- package/package.json +1 -1
- package/websocket-manager.ts +29 -3
|
@@ -8,6 +8,13 @@ import { eventHelper } from "../backend-handler";
|
|
|
8
8
|
|
|
9
9
|
type Security = string;
|
|
10
10
|
function extractErrorInfo(error: unknown): { code: string; message: string } {
|
|
11
|
+
if ((error as any)?.isTimeout) {
|
|
12
|
+
return {
|
|
13
|
+
code: "timeout",
|
|
14
|
+
message:
|
|
15
|
+
"The request is taking too long, but it does not mean it failed. If you need more help, please contact support.",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
11
18
|
const err = (error as any)?.error;
|
|
12
19
|
return {
|
|
13
20
|
code: err?.code ?? "unknown_error",
|
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,16 +452,23 @@ export const makeGlobalWebSocketRequest = async (
|
|
|
443
452
|
new Error(`Request timeout for ${topic}`),
|
|
444
453
|
);
|
|
445
454
|
}
|
|
446
|
-
|
|
455
|
+
if (purgeEnvKey) purgingEnvironments.delete(purgeEnvKey);
|
|
456
|
+
const timeoutError = Object.assign(
|
|
457
|
+
new Error(`Request timeout for ${topic}`),
|
|
458
|
+
{ isTimeout: true },
|
|
459
|
+
);
|
|
460
|
+
reject(timeoutError);
|
|
447
461
|
}, timeout);
|
|
448
462
|
|
|
449
463
|
const operation: PendingOperation = {
|
|
450
464
|
resolve: (response: any) => {
|
|
451
465
|
clearTimeout(timeoutId);
|
|
466
|
+
if (purgeEnvKey) purgingEnvironments.delete(purgeEnvKey);
|
|
452
467
|
resolve(response.payload || response);
|
|
453
468
|
},
|
|
454
469
|
reject: (error: any) => {
|
|
455
470
|
clearTimeout(timeoutId);
|
|
471
|
+
if (purgeEnvKey) purgingEnvironments.delete(purgeEnvKey);
|
|
456
472
|
const errorMessage = safeStringifyError(error);
|
|
457
473
|
console.error(`WebSocket request failed for ${topic}:`, {
|
|
458
474
|
originalError: error,
|
|
@@ -678,7 +694,18 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
678
694
|
);
|
|
679
695
|
}
|
|
680
696
|
const envSetKey = parentParts.tenant && parentParts.account ? `${parentParts.tenant}/${parentParts.account}/${entityId}` : entityId;
|
|
681
|
-
|
|
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);
|
|
682
709
|
const envTenant = tenantsMap.get(envEventResult.tenantId);
|
|
683
710
|
if (!envTenant) {
|
|
684
711
|
pendingEnvironments.push({
|
|
@@ -1563,7 +1590,6 @@ const handleOperationError = (operation: PendingOperation, error: any) => {
|
|
|
1563
1590
|
} else if (accErrorResult.eventType === "deletionError") {
|
|
1564
1591
|
eventHelper.account.publish.deletionError(originalData);
|
|
1565
1592
|
}
|
|
1566
|
-
eventHelper.notification.publish.creation(accErrorResult.notification);
|
|
1567
1593
|
break;
|
|
1568
1594
|
case "environment":
|
|
1569
1595
|
const envErrorResult = handleEnvironmentOperationError({
|