Skip to content

Commit 623f939

Browse files
committed
fixup: dont merge ctx uneccessarily
Signed-off-by: Todd Baert <[email protected]>
1 parent ac2caa2 commit 623f939

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

packages/server/src/client/internal/open-feature-client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,10 @@ export class OpenFeatureClient implements Client {
228228
try {
229229
this.shortCircuitIfNotReady();
230230

231-
const mergedContext = this.mergeContexts(context);
232-
Object.freeze(mergedContext);
233-
234231
if (typeof this._provider.track === 'function') {
235-
return this._provider.track?.(occurrenceKey, mergedContext, occurrenceDetails);
232+
// freeze the merged context
233+
const frozenContext = Object.freeze(this.mergeContexts(context));
234+
return this._provider.track?.(occurrenceKey, frozenContext, occurrenceDetails);
236235
} else {
237236
this._logger.debug('Provider does not support the track function; will no-op.');
238237
}

packages/web/src/client/internal/open-feature-client.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,12 @@ export class OpenFeatureClient implements Client {
186186
try {
187187
this.shortCircuitIfNotReady();
188188

189-
// copy and freeze the context
190-
const context = {
191-
...OpenFeature.getContext(this?.options?.domain),
192-
};
193-
Object.freeze(context);
194-
195189
if (typeof this._provider.track === 'function') {
196-
return this._provider.track?.(occurrenceKey, context, occurrenceDetails);
190+
// copy and freeze the context
191+
const frozenContext = Object.freeze({
192+
...OpenFeature.getContext(this?.options?.domain),
193+
});
194+
return this._provider.track?.(occurrenceKey, frozenContext, occurrenceDetails);
197195
} else {
198196
this._logger.debug('Provider does not support the track function; will no-op.');
199197
}

packages/web/src/provider/in-memory-provider/in-memory-provider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ export class InMemoryProvider implements Provider {
3838
*/
3939
async putConfiguration(flagConfiguration: FlagConfiguration) {
4040
try {
41-
const flagsChanged = Object.entries(flagConfiguration)
42-
.filter(([key, value]) => this._flagConfiguration[key] !== value)
41+
const flagsChanged = Object.entries({...flagConfiguration, ...this._flagConfiguration})
4342
.map(([key]) => key);
4443

4544
this._flagConfiguration = { ...flagConfiguration };

0 commit comments

Comments
 (0)