@splitsoftware/splitio-commons 1.17.2-rc.1 → 1.17.2-rc.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.
|
@@ -135,33 +135,29 @@ function splitChangesUpdaterFactory(log, splitChangesFetcher, splits, segments,
|
|
|
135
135
|
log.debug(constants_2.SYNC_SPLITS_REMOVED, [mutation.removed.length]);
|
|
136
136
|
log.debug(constants_2.SYNC_SPLITS_SEGMENTS, [mutation.segments.length]);
|
|
137
137
|
// Write into storage
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
return true;
|
|
159
|
-
});
|
|
138
|
+
return Promise.all([
|
|
139
|
+
splits.addSplits(mutation.added),
|
|
140
|
+
splits.removeSplits(mutation.removed),
|
|
141
|
+
segments.registerSegments(mutation.segments)
|
|
142
|
+
]).then(function (flagsChange) {
|
|
143
|
+
splits.setChangeNumber(splitChanges.till);
|
|
144
|
+
startingUp = false;
|
|
145
|
+
if (splitsEventEmitter) {
|
|
146
|
+
// To emit SDK_SPLITS_ARRIVED for server-side SDK, we must check that all registered segments have been fetched
|
|
147
|
+
return Promise.resolve(!splitsEventEmitter.splitsArrived || (since !== splitChanges.till && isThereUpdate(flagsChange) && (isClientSide || checkAllSegmentsExist(segments))))
|
|
148
|
+
.catch(function () { return false; } /** noop. just to handle a possible `checkAllSegmentsExist` rejection, before emitting SDK event */)
|
|
149
|
+
.then(function (emitSplitsArrivedEvent) {
|
|
150
|
+
// emit SDK events
|
|
151
|
+
if (emitSplitsArrivedEvent)
|
|
152
|
+
splitsEventEmitter.emit(constants_1.SDK_SPLITS_ARRIVED);
|
|
153
|
+
return true;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
160
157
|
});
|
|
161
158
|
})
|
|
162
159
|
.catch(function (error) {
|
|
163
160
|
log.warn(constants_2.SYNC_SPLITS_FETCH_FAILS, [error]);
|
|
164
|
-
console.log('startingUp', startingUp, 'retriesOnFailureBeforeReady', retriesOnFailureBeforeReady, 'retry', retry);
|
|
165
161
|
if (startingUp && retriesOnFailureBeforeReady > retry) {
|
|
166
162
|
retry += 1;
|
|
167
163
|
log.info(constants_2.SYNC_SPLITS_FETCH_RETRY, [retry, error]);
|
|
@@ -130,33 +130,29 @@ export function splitChangesUpdaterFactory(log, splitChangesFetcher, splits, seg
|
|
|
130
130
|
log.debug(SYNC_SPLITS_REMOVED, [mutation.removed.length]);
|
|
131
131
|
log.debug(SYNC_SPLITS_SEGMENTS, [mutation.segments.length]);
|
|
132
132
|
// Write into storage
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return true;
|
|
154
|
-
});
|
|
133
|
+
return Promise.all([
|
|
134
|
+
splits.addSplits(mutation.added),
|
|
135
|
+
splits.removeSplits(mutation.removed),
|
|
136
|
+
segments.registerSegments(mutation.segments)
|
|
137
|
+
]).then(function (flagsChange) {
|
|
138
|
+
splits.setChangeNumber(splitChanges.till);
|
|
139
|
+
startingUp = false;
|
|
140
|
+
if (splitsEventEmitter) {
|
|
141
|
+
// To emit SDK_SPLITS_ARRIVED for server-side SDK, we must check that all registered segments have been fetched
|
|
142
|
+
return Promise.resolve(!splitsEventEmitter.splitsArrived || (since !== splitChanges.till && isThereUpdate(flagsChange) && (isClientSide || checkAllSegmentsExist(segments))))
|
|
143
|
+
.catch(function () { return false; } /** noop. just to handle a possible `checkAllSegmentsExist` rejection, before emitting SDK event */)
|
|
144
|
+
.then(function (emitSplitsArrivedEvent) {
|
|
145
|
+
// emit SDK events
|
|
146
|
+
if (emitSplitsArrivedEvent)
|
|
147
|
+
splitsEventEmitter.emit(SDK_SPLITS_ARRIVED);
|
|
148
|
+
return true;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return true;
|
|
155
152
|
});
|
|
156
153
|
})
|
|
157
154
|
.catch(function (error) {
|
|
158
155
|
log.warn(SYNC_SPLITS_FETCH_FAILS, [error]);
|
|
159
|
-
console.log('startingUp', startingUp, 'retriesOnFailureBeforeReady', retriesOnFailureBeforeReady, 'retry', retry);
|
|
160
156
|
if (startingUp && retriesOnFailureBeforeReady > retry) {
|
|
161
157
|
retry += 1;
|
|
162
158
|
log.info(SYNC_SPLITS_FETCH_RETRY, [retry, error]);
|
package/package.json
CHANGED
|
@@ -165,33 +165,29 @@ export function splitChangesUpdaterFactory(
|
|
|
165
165
|
log.debug(SYNC_SPLITS_SEGMENTS, [mutation.segments.length]);
|
|
166
166
|
|
|
167
167
|
// Write into storage
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
return true;
|
|
189
|
-
});
|
|
168
|
+
return Promise.all([
|
|
169
|
+
splits.addSplits(mutation.added),
|
|
170
|
+
splits.removeSplits(mutation.removed),
|
|
171
|
+
segments.registerSegments(mutation.segments)
|
|
172
|
+
]).then((flagsChange) => {
|
|
173
|
+
splits.setChangeNumber(splitChanges.till);
|
|
174
|
+
startingUp = false;
|
|
175
|
+
|
|
176
|
+
if (splitsEventEmitter) {
|
|
177
|
+
// To emit SDK_SPLITS_ARRIVED for server-side SDK, we must check that all registered segments have been fetched
|
|
178
|
+
return Promise.resolve(!splitsEventEmitter.splitsArrived || (since !== splitChanges.till && isThereUpdate(flagsChange) && (isClientSide || checkAllSegmentsExist(segments))))
|
|
179
|
+
.catch(() => false /** noop. just to handle a possible `checkAllSegmentsExist` rejection, before emitting SDK event */)
|
|
180
|
+
.then(emitSplitsArrivedEvent => {
|
|
181
|
+
// emit SDK events
|
|
182
|
+
if (emitSplitsArrivedEvent) splitsEventEmitter.emit(SDK_SPLITS_ARRIVED);
|
|
183
|
+
return true;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
190
187
|
});
|
|
191
188
|
})
|
|
192
189
|
.catch(error => {
|
|
193
190
|
log.warn(SYNC_SPLITS_FETCH_FAILS, [error]);
|
|
194
|
-
console.log('startingUp', startingUp, 'retriesOnFailureBeforeReady', retriesOnFailureBeforeReady, 'retry', retry);
|
|
195
191
|
|
|
196
192
|
if (startingUp && retriesOnFailureBeforeReady > retry) {
|
|
197
193
|
retry += 1;
|