@statsig/client-core 3.25.5 → 3.26.0
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/src/NetworkCore.js +17 -19
- package/src/StatsigMetadata.d.ts +1 -1
- package/src/StatsigMetadata.js +1 -1
package/package.json
CHANGED
package/src/NetworkCore.js
CHANGED
|
@@ -108,10 +108,7 @@ class NetworkCore {
|
|
|
108
108
|
return null;
|
|
109
109
|
}
|
|
110
110
|
const currentAttempt = attempt !== null && attempt !== void 0 ? attempt : 1;
|
|
111
|
-
|
|
112
|
-
const timeoutHandle = setTimeout(() => {
|
|
113
|
-
abortController === null || abortController === void 0 ? void 0 : abortController.abort(`Timeout of ${this._timeout}ms expired.`);
|
|
114
|
-
}, this._timeout);
|
|
111
|
+
let reqTimedOut = false;
|
|
115
112
|
const populatedUrl = this._getPopulatedURL(args);
|
|
116
113
|
let response = null;
|
|
117
114
|
const keepalive = (0, VisibilityObserving_1._isUnloading)();
|
|
@@ -120,7 +117,6 @@ class NetworkCore {
|
|
|
120
117
|
method,
|
|
121
118
|
body,
|
|
122
119
|
headers: Object.assign({}, args.headers),
|
|
123
|
-
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
124
120
|
priority: args.priority,
|
|
125
121
|
keepalive,
|
|
126
122
|
};
|
|
@@ -131,8 +127,16 @@ class NetworkCore {
|
|
|
131
127
|
this._leakyBucket[endpoint] = bucket;
|
|
132
128
|
}
|
|
133
129
|
const func = (_a = this._netConfig.networkOverrideFunc) !== null && _a !== void 0 ? _a : fetch;
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
let timeoutId;
|
|
131
|
+
response = yield Promise.race([
|
|
132
|
+
func(populatedUrl, config).finally(() => clearTimeout(timeoutId)),
|
|
133
|
+
new Promise((_, reject) => {
|
|
134
|
+
timeoutId = setTimeout(() => {
|
|
135
|
+
reqTimedOut = true;
|
|
136
|
+
reject(new Error(`Timeout of ${this._timeout}ms expired.`));
|
|
137
|
+
}, this._timeout);
|
|
138
|
+
}),
|
|
139
|
+
]);
|
|
136
140
|
if (!response.ok) {
|
|
137
141
|
const text = yield response.text().catch(() => 'No Text');
|
|
138
142
|
const err = new Error(`NetworkError: ${populatedUrl} ${text}`);
|
|
@@ -148,8 +152,8 @@ class NetworkCore {
|
|
|
148
152
|
};
|
|
149
153
|
}
|
|
150
154
|
catch (error) {
|
|
151
|
-
const errorMessage = _getErrorMessage(
|
|
152
|
-
const timedOut = _didTimeout(
|
|
155
|
+
const errorMessage = _getErrorMessage(error);
|
|
156
|
+
const timedOut = _didTimeout(errorMessage !== null && errorMessage !== void 0 ? errorMessage : '', reqTimedOut);
|
|
153
157
|
_tryMarkInitEnd(args, response, currentAttempt, '', error);
|
|
154
158
|
const fallbackUpdated = yield this._fallbackResolver.tryFetchUpdatedFallbackInfo(args.sdkKey, args.urlConfig, errorMessage, timedOut);
|
|
155
159
|
if (fallbackUpdated) {
|
|
@@ -328,11 +332,7 @@ function _allowCompression(args, options) {
|
|
|
328
332
|
return false;
|
|
329
333
|
}
|
|
330
334
|
}
|
|
331
|
-
function _getErrorMessage(
|
|
332
|
-
if ((controller === null || controller === void 0 ? void 0 : controller.signal.aborted) &&
|
|
333
|
-
typeof controller.signal.reason === 'string') {
|
|
334
|
-
return controller.signal.reason;
|
|
335
|
-
}
|
|
335
|
+
function _getErrorMessage(error) {
|
|
336
336
|
if (typeof error === 'string') {
|
|
337
337
|
return error;
|
|
338
338
|
}
|
|
@@ -341,11 +341,9 @@ function _getErrorMessage(controller, error) {
|
|
|
341
341
|
}
|
|
342
342
|
return 'Unknown Error';
|
|
343
343
|
}
|
|
344
|
-
function _didTimeout(
|
|
345
|
-
const timeout = (
|
|
346
|
-
|
|
347
|
-
controller.signal.reason.includes('Timeout');
|
|
348
|
-
return timeout || false;
|
|
344
|
+
function _didTimeout(errorMsg, abortedByTimeout) {
|
|
345
|
+
const timeout = errorMsg.includes('Timeout'); // probably not needed but just in case
|
|
346
|
+
return timeout || abortedByTimeout;
|
|
349
347
|
}
|
|
350
348
|
function _tryMarkInitStart(args, attempt) {
|
|
351
349
|
if (args.urlConfig.endpoint !== NetworkConfig_1.Endpoint._initialize) {
|
package/src/StatsigMetadata.d.ts
CHANGED
package/src/StatsigMetadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
|
|
4
|
-
exports.SDK_VERSION = '3.
|
|
4
|
+
exports.SDK_VERSION = '3.26.0';
|
|
5
5
|
let metadata = {
|
|
6
6
|
sdkVersion: exports.SDK_VERSION,
|
|
7
7
|
sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
|