@configdirector/nuxt-sdk 1.14.1 → 1.14.3
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/module.d.mts +2 -1
- package/dist/module.json +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClient.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClient.d.ts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClientHooks.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorClientHooks.d.ts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorContext.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorContext.d.ts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorValue.d.mts +1 -1
- package/dist/runtime/app/composables/useConfigDirectorValue.d.ts +1 -1
- package/dist/runtime/{native-values-Cq3SCmEH.d.mts → native-values-BjAsU5SD.d.mts} +2 -1
- package/dist/runtime/nitro/offline-values.d.mts +1 -1
- package/dist/runtime/nitro/offline-values.d.ts +1 -1
- package/dist/runtime/nitro/plugin.d.mts +2 -2
- package/dist/runtime/nitro/plugin.d.ts +2 -2
- package/dist/runtime/nitro/plugin.mjs +15 -17
- package/dist/runtime/plugin.client.mjs +46 -20
- package/dist/runtime/server/composables/useConfigDirectorServerClient.d.mts +1 -1
- package/dist/runtime/server/composables/useConfigDirectorServerClient.d.ts +1 -1
- package/dist/runtime/server/composables/useConfigDirectorServerHooks.d.mts +1 -1
- package/dist/runtime/server/composables/useConfigDirectorServerHooks.d.ts +1 -1
- package/dist/runtime/{types-BNw2c3C0.d.mts → types-BOsBpju5.d.mts} +1 -1
- package/dist/runtime/{types-CYquNKWW.d.mts → types-BeMbqkgk.d.mts} +1 -1
- package/dist/testing.d.mts +2 -1
- package/dist/testing.mjs +46 -20
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -10,7 +10,8 @@ type ConfigValueType = string | number | boolean | object | ConfigEnumLikeType;
|
|
|
10
10
|
* Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
|
|
11
11
|
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
12
12
|
* `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
|
|
13
|
-
* percentage rollout because the context has no `id` to place it in a share
|
|
13
|
+
* percentage rollout because the context has no `id` to place it in a share, and no rule after
|
|
14
|
+
* the rollout applied. `value-missing`
|
|
14
15
|
* returns the in-code default value because the config has no value. Every other reason returns the
|
|
15
16
|
* in-code default value because of an error: the config does not exist (`config-state-missing`), no
|
|
16
17
|
* values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
|
package/dist/module.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-BOsBpju5.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/app/composables/useConfigDirectorClientHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorClientHooks: (hooks: ClientHooks) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-BOsBpju5.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/app/composables/useConfigDirectorClientHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorClientHooks: (hooks: ClientHooks) => void;
|
|
@@ -22,7 +22,8 @@ type ConfigState = {
|
|
|
22
22
|
* Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
|
|
23
23
|
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
24
24
|
* `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
|
|
25
|
-
* percentage rollout because the context has no `id` to place it in a share
|
|
25
|
+
* percentage rollout because the context has no `id` to place it in a share, and no rule after
|
|
26
|
+
* the rollout applied. `value-missing`
|
|
26
27
|
* returns the in-code default value because the config has no value. Every other reason returns the
|
|
27
28
|
* in-code default value because of an error: the config does not exist (`config-state-missing`), no
|
|
28
29
|
* values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ConnectionMode } from "../native-values-
|
|
2
|
-
import { n as ConfigDirectorClient } from "../types-
|
|
1
|
+
import { o as ConnectionMode } from "../native-values-BjAsU5SD.mjs";
|
|
2
|
+
import { n as ConfigDirectorClient } from "../types-BeMbqkgk.mjs";
|
|
3
3
|
import * as _$nitropack from "nitropack";
|
|
4
4
|
|
|
5
5
|
//#region src/runtime/nitro/plugin.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as ConnectionMode } from "../native-values-
|
|
2
|
-
import { n as ConfigDirectorClient } from "../types-
|
|
1
|
+
import { o as ConnectionMode } from "../native-values-BjAsU5SD.mjs";
|
|
2
|
+
import { n as ConfigDirectorClient } from "../types-BeMbqkgk.mjs";
|
|
3
3
|
import * as _$nitropack from "nitropack";
|
|
4
4
|
|
|
5
5
|
//#region src/runtime/nitro/plugin.d.ts
|
|
@@ -7281,8 +7281,9 @@ var ConfigEvaluator = class {
|
|
|
7281
7281
|
* Evaluate a config for a context and record how the value was reached: every rule in the
|
|
7282
7282
|
* order it was walked with its outcome, the conditions that were checked with what they
|
|
7283
7283
|
* resolved to, and the share a rollout assigned the context to. A rollout reached by a context
|
|
7284
|
-
* without an identifier is skipped
|
|
7285
|
-
*
|
|
7284
|
+
* without an identifier is skipped and the walk goes on to the next rule; when no later rule
|
|
7285
|
+
* applies, the default targeting rule value is served with the reason
|
|
7286
|
+
* `rollout-skipped-no-identifier`. `evaluate` is this walk with only
|
|
7286
7287
|
* the value, its value ID, its variation and the rollout share that served it kept, so the two
|
|
7287
7288
|
* cannot disagree. `segments` is the payload's segments map, which a segment condition looks
|
|
7288
7289
|
* its segment up in; a segment it does not hold never matches.
|
|
@@ -7293,7 +7294,7 @@ var ConfigEvaluator = class {
|
|
|
7293
7294
|
for (const rule of rules) {
|
|
7294
7295
|
const walkedRule = this.explainRule(rule, config, context, segments);
|
|
7295
7296
|
walkedRules.push(walkedRule);
|
|
7296
|
-
if (walkedRule.serving.kind
|
|
7297
|
+
if (walkedRule.serving.kind === "served") break;
|
|
7297
7298
|
}
|
|
7298
7299
|
const ruleExplanations = [...walkedRules.map((walkedRule) => walkedRule.explanation), ...rules.slice(walkedRules.length).map((rule) => ({
|
|
7299
7300
|
ruleId: rule.id,
|
|
@@ -7311,19 +7312,16 @@ var ConfigEvaluator = class {
|
|
|
7311
7312
|
rules: ruleExplanations
|
|
7312
7313
|
});
|
|
7313
7314
|
const lastServing = walkedRules[walkedRules.length - 1]?.serving ?? NOT_MATCHED;
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
case "rollout-skipped-no-identifier": return defaultTargetingRuleValue("rollout-skipped-no-identifier");
|
|
7325
|
-
case "not-matched": return defaultTargetingRuleValue("found-match");
|
|
7326
|
-
}
|
|
7315
|
+
if (lastServing.kind === "served") return {
|
|
7316
|
+
...lastServing.servedValue,
|
|
7317
|
+
reason: "found-match",
|
|
7318
|
+
servedBy: {
|
|
7319
|
+
kind: "rule",
|
|
7320
|
+
ruleId: lastServing.ruleId
|
|
7321
|
+
},
|
|
7322
|
+
rules: ruleExplanations
|
|
7323
|
+
};
|
|
7324
|
+
return defaultTargetingRuleValue(walkedRules.some((walkedRule) => walkedRule.serving.kind === "rollout-skipped-no-identifier") ? "rollout-skipped-no-identifier" : "found-match");
|
|
7327
7325
|
}
|
|
7328
7326
|
explainRule(rule, config, context, segments) {
|
|
7329
7327
|
const explanation = {
|
|
@@ -8714,7 +8712,7 @@ var plugin_default = defineNitroPlugin((nitroApp) => {
|
|
|
8714
8712
|
logger.debug("Initializing ConfigDirector Nitro plugin");
|
|
8715
8713
|
const client = new DefaultConfigDirectorClient(serverSdkKey || void 0, {
|
|
8716
8714
|
sdkName: "nuxt-sdk",
|
|
8717
|
-
sdkVersion: "1.14.
|
|
8715
|
+
sdkVersion: "1.14.3"
|
|
8718
8716
|
}, {
|
|
8719
8717
|
logger,
|
|
8720
8718
|
metadata: {
|
|
@@ -1172,12 +1172,12 @@ var PollingTransport = class extends AbstractPollingTransport {
|
|
|
1172
1172
|
this.endCurrentConnection();
|
|
1173
1173
|
const generation = this.connectionGeneration;
|
|
1174
1174
|
const clientSession = await this.options.clientSession;
|
|
1175
|
-
if (
|
|
1175
|
+
if (!this.isCurrentConnection(generation)) return this;
|
|
1176
1176
|
try {
|
|
1177
|
-
await this.fetchConfigs(context, timeout, clientSession);
|
|
1177
|
+
await this.fetchConfigs(context, timeout, clientSession, generation);
|
|
1178
1178
|
} finally {
|
|
1179
|
-
if (
|
|
1180
|
-
this.fetchConfigs(context, timeout, clientSession).catch((error) => {
|
|
1179
|
+
if (this.continuesPolling(generation)) this.schedulePollingInterval(() => {
|
|
1180
|
+
this.fetchConfigs(context, timeout, clientSession, generation).catch((error) => {
|
|
1181
1181
|
this.logger.error("[PollingTransport] Error during polling:", error);
|
|
1182
1182
|
});
|
|
1183
1183
|
});
|
|
@@ -1193,7 +1193,13 @@ var PollingTransport = class extends AbstractPollingTransport {
|
|
|
1193
1193
|
this.clearPollingInterval();
|
|
1194
1194
|
this.lastUpdateTimestamp = void 0;
|
|
1195
1195
|
}
|
|
1196
|
-
|
|
1196
|
+
isCurrentConnection(generation) {
|
|
1197
|
+
return generation === this.connectionGeneration;
|
|
1198
|
+
}
|
|
1199
|
+
continuesPolling(generation) {
|
|
1200
|
+
return !this.fatalError && this.isCurrentConnection(generation);
|
|
1201
|
+
}
|
|
1202
|
+
async fetchConfigs(context, timeout, clientSession, generation) {
|
|
1197
1203
|
if (this.fatalError) {
|
|
1198
1204
|
this.logger.warn("[PollingTransport] There was a prior unrecoverable error. Ignoring attempt to reconnect.");
|
|
1199
1205
|
return;
|
|
@@ -1214,6 +1220,7 @@ var PollingTransport = class extends AbstractPollingTransport {
|
|
|
1214
1220
|
await this.handleNonOkResponse(response);
|
|
1215
1221
|
if (response.status == 200) {
|
|
1216
1222
|
const json = JSON.parse(await response.text());
|
|
1223
|
+
if (!this.isCurrentConnection(generation)) return;
|
|
1217
1224
|
this.lastUpdateTimestamp = json.timestamp;
|
|
1218
1225
|
this.eventEmitter.emit("configSetReceived", json);
|
|
1219
1226
|
}
|
|
@@ -1554,6 +1561,21 @@ var CachedValuesStore = class {
|
|
|
1554
1561
|
//#endregion
|
|
1555
1562
|
//#region ../js-client-core/src/DefaultConfigDirectorClient.ts
|
|
1556
1563
|
const MAX_EXPONENTIAL_DELAY = 9;
|
|
1564
|
+
const createReadyOrClosedSignal = () => {
|
|
1565
|
+
let raise;
|
|
1566
|
+
return {
|
|
1567
|
+
raised: new Promise((resolve) => {
|
|
1568
|
+
raise = resolve;
|
|
1569
|
+
}),
|
|
1570
|
+
raise
|
|
1571
|
+
};
|
|
1572
|
+
};
|
|
1573
|
+
const waitAtMost = async (timeout, awaited) => {
|
|
1574
|
+
let timeoutTimer;
|
|
1575
|
+
await Promise.race([awaited, new Promise((resolve) => {
|
|
1576
|
+
timeoutTimer = setTimeout(() => resolve(), timeout);
|
|
1577
|
+
})]).finally(() => clearTimeout(timeoutTimer));
|
|
1578
|
+
};
|
|
1557
1579
|
var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
1558
1580
|
logger;
|
|
1559
1581
|
telemetryClient;
|
|
@@ -1562,14 +1584,14 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1562
1584
|
transport;
|
|
1563
1585
|
eventEmitter = new Emitter();
|
|
1564
1586
|
timeout;
|
|
1565
|
-
timeoutTimer;
|
|
1566
1587
|
ready = false;
|
|
1567
1588
|
initializing = false;
|
|
1568
1589
|
hasReceivedConfigSet = false;
|
|
1569
|
-
readyPromise;
|
|
1570
1590
|
readyResolve;
|
|
1591
|
+
readyOrClosedSignal = createReadyOrClosedSignal();
|
|
1571
1592
|
currentContext;
|
|
1572
1593
|
submittedContext;
|
|
1594
|
+
latestConnectAttempt = 0;
|
|
1573
1595
|
connectionPlan;
|
|
1574
1596
|
clientSession;
|
|
1575
1597
|
cachedValuesStore;
|
|
@@ -1789,31 +1811,28 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1789
1811
|
return this.currentContext;
|
|
1790
1812
|
}
|
|
1791
1813
|
async connectToTransport(context, caller) {
|
|
1814
|
+
const attempt = ++this.latestConnectAttempt;
|
|
1815
|
+
const readyOrClosed = this.readyOrClosedSignal.raised;
|
|
1792
1816
|
this.submittedContext = context;
|
|
1793
1817
|
if (caller === "initialization") this.startCachedValuesAdoption();
|
|
1794
1818
|
try {
|
|
1795
1819
|
this.ready = false;
|
|
1796
|
-
|
|
1820
|
+
new Promise((resolve) => {
|
|
1797
1821
|
this.readyResolve = resolve;
|
|
1798
1822
|
}).then((cancelled) => {
|
|
1799
1823
|
if (cancelled) return;
|
|
1800
1824
|
this.ready = true;
|
|
1801
1825
|
this.initializing = false;
|
|
1826
|
+
this.signalReadyOrClosed();
|
|
1802
1827
|
this.emit("clientReady", { action: caller });
|
|
1803
1828
|
this.logger.debug("[ConfigDirectorClient] Received initial payload from the server, client is ready");
|
|
1804
1829
|
});
|
|
1805
1830
|
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1806
1831
|
await this.transport.connect(context ?? {}, this.timeout, caller);
|
|
1807
|
-
this.
|
|
1808
|
-
this.telemetryClient.updateContext(context).catch((error) => this.logger.warn("[ConfigDirectorClient] Telemetry could not update the context: ", error));
|
|
1809
|
-
this.emit("contextUpdated", { context });
|
|
1832
|
+
if (attempt === this.latestConnectAttempt) this.adoptContext(context);
|
|
1810
1833
|
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - startTime;
|
|
1811
1834
|
const remainingTimeout = this.timeout - elapsedTime;
|
|
1812
|
-
|
|
1813
|
-
this.timeoutTimer = void 0;
|
|
1814
|
-
if (remainingTimeout > 0) await Promise.race([this.readyPromise, new Promise((resolve) => {
|
|
1815
|
-
this.timeoutTimer = setTimeout(() => resolve(), remainingTimeout);
|
|
1816
|
-
})]).finally(() => clearTimeout(this.timeoutTimer));
|
|
1835
|
+
if (remainingTimeout > 0) await waitAtMost(remainingTimeout, readyOrClosed);
|
|
1817
1836
|
if (!this.ready) this.logger.warn(`[ConfigDirectorClient] Timed out waiting for ${caller} after ${this.timeout}ms. ${this.timeoutWarningDetails()}`);
|
|
1818
1837
|
} catch (error) {
|
|
1819
1838
|
if (error instanceof ConfigDirectorInitializationError) {
|
|
@@ -1823,6 +1842,15 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1823
1842
|
this.logger.error(`[ConfigDirectorClient] An error occurred during ${caller}: `, error);
|
|
1824
1843
|
}
|
|
1825
1844
|
}
|
|
1845
|
+
adoptContext(context) {
|
|
1846
|
+
this.currentContext = context;
|
|
1847
|
+
this.telemetryClient.updateContext(context).catch((error) => this.logger.warn("[ConfigDirectorClient] Telemetry could not update the context: ", error));
|
|
1848
|
+
this.emit("contextUpdated", { context });
|
|
1849
|
+
}
|
|
1850
|
+
signalReadyOrClosed() {
|
|
1851
|
+
this.readyOrClosedSignal.raise();
|
|
1852
|
+
this.readyOrClosedSignal = createReadyOrClosedSignal();
|
|
1853
|
+
}
|
|
1826
1854
|
timeoutWarningDetails() {
|
|
1827
1855
|
switch (this.connectionPlan.kind) {
|
|
1828
1856
|
case "connect": return "The client will continue to retry since there were no fatal errors detected. Configs will return the default value until the connection succeeds.";
|
|
@@ -1975,8 +2003,6 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1975
2003
|
case "stay-offline": return;
|
|
1976
2004
|
case "connect":
|
|
1977
2005
|
this.logger.debug("[ConfigDirectorClient] pauseNetwork() called, pausing transport connection");
|
|
1978
|
-
clearTimeout(this.timeoutTimer);
|
|
1979
|
-
this.timeoutTimer = void 0;
|
|
1980
2006
|
this.transport.close();
|
|
1981
2007
|
this.ready = false;
|
|
1982
2008
|
return;
|
|
@@ -1992,12 +2018,12 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1992
2018
|
}
|
|
1993
2019
|
async close() {
|
|
1994
2020
|
this.logger.debug("[ConfigDirectorClient] close() has been called, closing connection to server");
|
|
1995
|
-
clearTimeout(this.timeoutTimer);
|
|
1996
2021
|
this.readyResolve?.(true);
|
|
1997
2022
|
this.telemetryClient.close().catch((error) => this.logger.warn("[ConfigDirectorClient] Telemetry could not close: ", error));
|
|
1998
2023
|
this.transport.close();
|
|
1999
2024
|
this.ready = false;
|
|
2000
2025
|
this.initializing = false;
|
|
2026
|
+
this.signalReadyOrClosed();
|
|
2001
2027
|
}
|
|
2002
2028
|
dispose() {
|
|
2003
2029
|
this.clear();
|
|
@@ -2574,7 +2600,7 @@ const buildClient = async (configdirector, logger) => {
|
|
|
2574
2600
|
return {
|
|
2575
2601
|
client: createBrowserClient(configdirector?.clientSdkKey || void 0, {
|
|
2576
2602
|
sdkName: "nuxt-sdk",
|
|
2577
|
-
sdkVersion: "1.14.
|
|
2603
|
+
sdkVersion: "1.14.3"
|
|
2578
2604
|
}, {
|
|
2579
2605
|
metadata: {
|
|
2580
2606
|
appName: configdirector?.appName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ConfigDirectorClient } from "../../types-
|
|
1
|
+
import { n as ConfigDirectorClient } from "../../types-BeMbqkgk.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerClient.d.ts
|
|
4
4
|
declare const useConfigDirectorServerClient: () => ConfigDirectorClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ConfigDirectorClient } from "../../types-
|
|
1
|
+
import { n as ConfigDirectorClient } from "../../types-BeMbqkgk.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerClient.d.ts
|
|
4
4
|
declare const useConfigDirectorServerClient: () => ConfigDirectorClient;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-BeMbqkgk.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorServerHooks: (hooks: ClientHooks) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ClientHooks } from "../../types-
|
|
1
|
+
import { t as ClientHooks } from "../../types-BeMbqkgk.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/server/composables/useConfigDirectorServerHooks.d.ts
|
|
4
4
|
declare const useConfigDirectorServerHooks: (hooks: ClientHooks) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ConfigValueType, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-
|
|
1
|
+
import { a as ConfigValueType, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-BjAsU5SD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../js-client-core/src/Emitter.d.ts
|
|
4
4
|
type EventType = string | symbol;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ConfigValueType, i as ConfigState, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-
|
|
1
|
+
import { a as ConfigValueType, i as ConfigState, n as ConfigDirectorContext, r as ConfigEvaluation, s as TrackOptions } from "./native-values-BjAsU5SD.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../js-server-sdk/src/types.d.ts
|
|
4
4
|
type ClientEvents = {
|
package/dist/testing.d.mts
CHANGED
|
@@ -23,7 +23,8 @@ interface ConfigDirectorLogger {
|
|
|
23
23
|
* Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
|
|
24
24
|
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
25
25
|
* `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
|
|
26
|
-
* percentage rollout because the context has no `id` to place it in a share
|
|
26
|
+
* percentage rollout because the context has no `id` to place it in a share, and no rule after
|
|
27
|
+
* the rollout applied. `value-missing`
|
|
27
28
|
* returns the in-code default value because the config has no value. Every other reason returns the
|
|
28
29
|
* in-code default value because of an error: the config does not exist (`config-state-missing`), no
|
|
29
30
|
* values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
|
package/dist/testing.mjs
CHANGED
|
@@ -1169,12 +1169,12 @@ var PollingTransport = class extends AbstractPollingTransport {
|
|
|
1169
1169
|
this.endCurrentConnection();
|
|
1170
1170
|
const generation = this.connectionGeneration;
|
|
1171
1171
|
const clientSession = await this.options.clientSession;
|
|
1172
|
-
if (
|
|
1172
|
+
if (!this.isCurrentConnection(generation)) return this;
|
|
1173
1173
|
try {
|
|
1174
|
-
await this.fetchConfigs(context, timeout, clientSession);
|
|
1174
|
+
await this.fetchConfigs(context, timeout, clientSession, generation);
|
|
1175
1175
|
} finally {
|
|
1176
|
-
if (
|
|
1177
|
-
this.fetchConfigs(context, timeout, clientSession).catch((error) => {
|
|
1176
|
+
if (this.continuesPolling(generation)) this.schedulePollingInterval(() => {
|
|
1177
|
+
this.fetchConfigs(context, timeout, clientSession, generation).catch((error) => {
|
|
1178
1178
|
this.logger.error("[PollingTransport] Error during polling:", error);
|
|
1179
1179
|
});
|
|
1180
1180
|
});
|
|
@@ -1190,7 +1190,13 @@ var PollingTransport = class extends AbstractPollingTransport {
|
|
|
1190
1190
|
this.clearPollingInterval();
|
|
1191
1191
|
this.lastUpdateTimestamp = void 0;
|
|
1192
1192
|
}
|
|
1193
|
-
|
|
1193
|
+
isCurrentConnection(generation) {
|
|
1194
|
+
return generation === this.connectionGeneration;
|
|
1195
|
+
}
|
|
1196
|
+
continuesPolling(generation) {
|
|
1197
|
+
return !this.fatalError && this.isCurrentConnection(generation);
|
|
1198
|
+
}
|
|
1199
|
+
async fetchConfigs(context, timeout, clientSession, generation) {
|
|
1194
1200
|
if (this.fatalError) {
|
|
1195
1201
|
this.logger.warn("[PollingTransport] There was a prior unrecoverable error. Ignoring attempt to reconnect.");
|
|
1196
1202
|
return;
|
|
@@ -1211,6 +1217,7 @@ var PollingTransport = class extends AbstractPollingTransport {
|
|
|
1211
1217
|
await this.handleNonOkResponse(response);
|
|
1212
1218
|
if (response.status == 200) {
|
|
1213
1219
|
const json = JSON.parse(await response.text());
|
|
1220
|
+
if (!this.isCurrentConnection(generation)) return;
|
|
1214
1221
|
this.lastUpdateTimestamp = json.timestamp;
|
|
1215
1222
|
this.eventEmitter.emit("configSetReceived", json);
|
|
1216
1223
|
}
|
|
@@ -1542,6 +1549,21 @@ var CachedValuesStore = class {
|
|
|
1542
1549
|
//#endregion
|
|
1543
1550
|
//#region ../js-client-core/src/DefaultConfigDirectorClient.ts
|
|
1544
1551
|
const MAX_EXPONENTIAL_DELAY = 9;
|
|
1552
|
+
const createReadyOrClosedSignal = () => {
|
|
1553
|
+
let raise;
|
|
1554
|
+
return {
|
|
1555
|
+
raised: new Promise((resolve) => {
|
|
1556
|
+
raise = resolve;
|
|
1557
|
+
}),
|
|
1558
|
+
raise
|
|
1559
|
+
};
|
|
1560
|
+
};
|
|
1561
|
+
const waitAtMost = async (timeout, awaited) => {
|
|
1562
|
+
let timeoutTimer;
|
|
1563
|
+
await Promise.race([awaited, new Promise((resolve) => {
|
|
1564
|
+
timeoutTimer = setTimeout(() => resolve(), timeout);
|
|
1565
|
+
})]).finally(() => clearTimeout(timeoutTimer));
|
|
1566
|
+
};
|
|
1545
1567
|
var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
1546
1568
|
logger;
|
|
1547
1569
|
telemetryClient;
|
|
@@ -1550,14 +1572,14 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1550
1572
|
transport;
|
|
1551
1573
|
eventEmitter = new Emitter();
|
|
1552
1574
|
timeout;
|
|
1553
|
-
timeoutTimer;
|
|
1554
1575
|
ready = false;
|
|
1555
1576
|
initializing = false;
|
|
1556
1577
|
hasReceivedConfigSet = false;
|
|
1557
|
-
readyPromise;
|
|
1558
1578
|
readyResolve;
|
|
1579
|
+
readyOrClosedSignal = createReadyOrClosedSignal();
|
|
1559
1580
|
currentContext;
|
|
1560
1581
|
submittedContext;
|
|
1582
|
+
latestConnectAttempt = 0;
|
|
1561
1583
|
connectionPlan;
|
|
1562
1584
|
clientSession;
|
|
1563
1585
|
cachedValuesStore;
|
|
@@ -1777,31 +1799,28 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1777
1799
|
return this.currentContext;
|
|
1778
1800
|
}
|
|
1779
1801
|
async connectToTransport(context, caller) {
|
|
1802
|
+
const attempt = ++this.latestConnectAttempt;
|
|
1803
|
+
const readyOrClosed = this.readyOrClosedSignal.raised;
|
|
1780
1804
|
this.submittedContext = context;
|
|
1781
1805
|
if (caller === "initialization") this.startCachedValuesAdoption();
|
|
1782
1806
|
try {
|
|
1783
1807
|
this.ready = false;
|
|
1784
|
-
|
|
1808
|
+
new Promise((resolve) => {
|
|
1785
1809
|
this.readyResolve = resolve;
|
|
1786
1810
|
}).then((cancelled) => {
|
|
1787
1811
|
if (cancelled) return;
|
|
1788
1812
|
this.ready = true;
|
|
1789
1813
|
this.initializing = false;
|
|
1814
|
+
this.signalReadyOrClosed();
|
|
1790
1815
|
this.emit("clientReady", { action: caller });
|
|
1791
1816
|
this.logger.debug("[ConfigDirectorClient] Received initial payload from the server, client is ready");
|
|
1792
1817
|
});
|
|
1793
1818
|
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1794
1819
|
await this.transport.connect(context ?? {}, this.timeout, caller);
|
|
1795
|
-
this.
|
|
1796
|
-
this.telemetryClient.updateContext(context).catch((error) => this.logger.warn("[ConfigDirectorClient] Telemetry could not update the context: ", error));
|
|
1797
|
-
this.emit("contextUpdated", { context });
|
|
1820
|
+
if (attempt === this.latestConnectAttempt) this.adoptContext(context);
|
|
1798
1821
|
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - startTime;
|
|
1799
1822
|
const remainingTimeout = this.timeout - elapsedTime;
|
|
1800
|
-
|
|
1801
|
-
this.timeoutTimer = void 0;
|
|
1802
|
-
if (remainingTimeout > 0) await Promise.race([this.readyPromise, new Promise((resolve) => {
|
|
1803
|
-
this.timeoutTimer = setTimeout(() => resolve(), remainingTimeout);
|
|
1804
|
-
})]).finally(() => clearTimeout(this.timeoutTimer));
|
|
1823
|
+
if (remainingTimeout > 0) await waitAtMost(remainingTimeout, readyOrClosed);
|
|
1805
1824
|
if (!this.ready) this.logger.warn(`[ConfigDirectorClient] Timed out waiting for ${caller} after ${this.timeout}ms. ${this.timeoutWarningDetails()}`);
|
|
1806
1825
|
} catch (error) {
|
|
1807
1826
|
if (error instanceof ConfigDirectorInitializationError) {
|
|
@@ -1811,6 +1830,15 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1811
1830
|
this.logger.error(`[ConfigDirectorClient] An error occurred during ${caller}: `, error);
|
|
1812
1831
|
}
|
|
1813
1832
|
}
|
|
1833
|
+
adoptContext(context) {
|
|
1834
|
+
this.currentContext = context;
|
|
1835
|
+
this.telemetryClient.updateContext(context).catch((error) => this.logger.warn("[ConfigDirectorClient] Telemetry could not update the context: ", error));
|
|
1836
|
+
this.emit("contextUpdated", { context });
|
|
1837
|
+
}
|
|
1838
|
+
signalReadyOrClosed() {
|
|
1839
|
+
this.readyOrClosedSignal.raise();
|
|
1840
|
+
this.readyOrClosedSignal = createReadyOrClosedSignal();
|
|
1841
|
+
}
|
|
1814
1842
|
timeoutWarningDetails() {
|
|
1815
1843
|
switch (this.connectionPlan.kind) {
|
|
1816
1844
|
case "connect": return "The client will continue to retry since there were no fatal errors detected. Configs will return the default value until the connection succeeds.";
|
|
@@ -1963,8 +1991,6 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1963
1991
|
case "stay-offline": return;
|
|
1964
1992
|
case "connect":
|
|
1965
1993
|
this.logger.debug("[ConfigDirectorClient] pauseNetwork() called, pausing transport connection");
|
|
1966
|
-
clearTimeout(this.timeoutTimer);
|
|
1967
|
-
this.timeoutTimer = void 0;
|
|
1968
1994
|
this.transport.close();
|
|
1969
1995
|
this.ready = false;
|
|
1970
1996
|
return;
|
|
@@ -1980,12 +2006,12 @@ var DefaultConfigDirectorClient = class DefaultConfigDirectorClient {
|
|
|
1980
2006
|
}
|
|
1981
2007
|
async close() {
|
|
1982
2008
|
this.logger.debug("[ConfigDirectorClient] close() has been called, closing connection to server");
|
|
1983
|
-
clearTimeout(this.timeoutTimer);
|
|
1984
2009
|
this.readyResolve?.(true);
|
|
1985
2010
|
this.telemetryClient.close().catch((error) => this.logger.warn("[ConfigDirectorClient] Telemetry could not close: ", error));
|
|
1986
2011
|
this.transport.close();
|
|
1987
2012
|
this.ready = false;
|
|
1988
2013
|
this.initializing = false;
|
|
2014
|
+
this.signalReadyOrClosed();
|
|
1989
2015
|
}
|
|
1990
2016
|
dispose() {
|
|
1991
2017
|
this.clear();
|
|
@@ -2312,7 +2338,7 @@ const installTestClient = (testClient) => {
|
|
|
2312
2338
|
const createTestClient = (options) => {
|
|
2313
2339
|
return createTestClient$1({
|
|
2314
2340
|
sdkName: "nuxt-sdk",
|
|
2315
|
-
sdkVersion: "1.14.
|
|
2341
|
+
sdkVersion: "1.14.3"
|
|
2316
2342
|
}, options);
|
|
2317
2343
|
};
|
|
2318
2344
|
//#endregion
|
package/package.json
CHANGED