@aexhq/sdk 0.59.0 → 0.59.2
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/dist/session.js +31 -4
- package/package.json +2 -2
package/dist/session.js
CHANGED
|
@@ -9,6 +9,7 @@ export class Sessions {
|
|
|
9
9
|
#webSocketFactory;
|
|
10
10
|
#customerEnvironments = new Map();
|
|
11
11
|
#customerEnvironmentInstances = new Map();
|
|
12
|
+
#customerEnvironmentReadinessWaiters = new Map();
|
|
12
13
|
#closed = false;
|
|
13
14
|
constructor(transport, webSocketFactory) {
|
|
14
15
|
this.#transport = transport;
|
|
@@ -237,16 +238,42 @@ export class Sessions {
|
|
|
237
238
|
}
|
|
238
239
|
}
|
|
239
240
|
});
|
|
240
|
-
|
|
241
|
-
// later sessions. Its grant/reconnect lifetime must never inherit one create signal.
|
|
242
|
-
await waitWithSignal(starting, signal);
|
|
241
|
+
await this.#waitForCustomerEnvironmentReadiness(clientId, starting, signal);
|
|
243
242
|
return;
|
|
244
243
|
}
|
|
245
|
-
const hand = await
|
|
244
|
+
const hand = await this.#waitForCustomerEnvironmentReadiness(clientId, existing, signal);
|
|
246
245
|
if (this.#closed)
|
|
247
246
|
throw new SessionError("Aex client is closed");
|
|
248
247
|
await waitWithSignal(hand.register(registrations), signal);
|
|
249
248
|
}
|
|
249
|
+
async #waitForCustomerEnvironmentReadiness(clientId, starting, signal) {
|
|
250
|
+
this.#customerEnvironmentReadinessWaiters.set(clientId, (this.#customerEnvironmentReadinessWaiters.get(clientId) ?? 0) + 1);
|
|
251
|
+
let settled = false;
|
|
252
|
+
void starting.then(() => { settled = true; }, () => { settled = true; });
|
|
253
|
+
try {
|
|
254
|
+
return await waitWithSignal(starting, signal);
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
if (signal?.aborted && !settled
|
|
258
|
+
&& this.#customerEnvironmentReadinessWaiters.get(clientId) === 1
|
|
259
|
+
&& this.#customerEnvironments.get(clientId) === starting) {
|
|
260
|
+
const partial = this.#customerEnvironmentInstances.get(clientId);
|
|
261
|
+
partial?.close();
|
|
262
|
+
this.#customerEnvironments.delete(clientId);
|
|
263
|
+
if (this.#customerEnvironmentInstances.get(clientId) === partial) {
|
|
264
|
+
this.#customerEnvironmentInstances.delete(clientId);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
finally {
|
|
270
|
+
const waiters = this.#customerEnvironmentReadinessWaiters.get(clientId) ?? 1;
|
|
271
|
+
if (waiters <= 1)
|
|
272
|
+
this.#customerEnvironmentReadinessWaiters.delete(clientId);
|
|
273
|
+
else
|
|
274
|
+
this.#customerEnvironmentReadinessWaiters.set(clientId, waiters - 1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
250
277
|
}
|
|
251
278
|
function isApplicationEnvironment(value) {
|
|
252
279
|
const config = value.config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/sdk",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.2",
|
|
4
4
|
"description": "TypeScript SDK for Aex sessions",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://aex.dev",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"test": "tsc -p tsconfig.json && node --test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@aexhq/brain": "0.3.
|
|
37
|
+
"@aexhq/brain": "0.3.3",
|
|
38
38
|
"@aexhq/env-app": "0.2.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|