Skip to content

Commit 9c59f55

Browse files
authored
Update the condition in RC service of performance to allow config objects with no entries (#1747)
1 parent 46213bb commit 9c59f55

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/performance/src/services/remote_config_service.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,21 @@ describe('Performance Monitoring > remote_config_service', () => {
176176

177177
expect(SettingsService.getInstance().loggingEnabled).to.be.true;
178178
});
179+
180+
it('uses secondary configs if the response does not have any fields', async () => {
181+
// Expired local config.
182+
const EXPIRY_LOCAL_STORAGE_VALUE = '1556524895320';
183+
storageGetItemStub.callsFake(
184+
storageGetItemFakeFactory(
185+
EXPIRY_LOCAL_STORAGE_VALUE,
186+
'not a valid config and should not be used'
187+
)
188+
);
189+
const STRINGIFIED_PARTIAL_CONFIG = '{"state":"NO TEMPLATE"}';
190+
fetchStub.resolves(new Response(STRINGIFIED_PARTIAL_CONFIG));
191+
await getConfig(IID);
192+
193+
expect(SettingsService.getInstance().loggingEnabled).to.be.true;
194+
});
179195
});
180196
});

packages/performance/src/services/remote_config_service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ function getRemoteConfig(
147147
function processConfig(
148148
config: RemoteConfigResponse | undefined
149149
): RemoteConfigResponse | undefined {
150-
if (!config || !config.entries) return config;
150+
if (!config) return config;
151151
const settingsServiceInstance = SettingsService.getInstance();
152-
const entries = config.entries;
152+
const entries = config.entries || {};
153153
if (entries.fpr_enabled !== undefined) {
154154
// TODO: Change the assignment of loggingEnabled once the received type is known.
155155
settingsServiceInstance.loggingEnabled =

0 commit comments

Comments
 (0)