diff --git a/src/config.js b/src/config.js index 30ab8f35e2c..5e89210dfcb 100644 --- a/src/config.js +++ b/src/config.js @@ -386,7 +386,11 @@ export function newConfig() { option = Object.assign({}, defaults[topic], option); } - topicalConfig[topic] = config[topic] = option; + try { + topicalConfig[topic] = config[topic] = option; + } catch (e) { + logWarn(`Cannot set config for property ${topic} : `, e) + } }); callSubscribers(topicalConfig); @@ -525,11 +529,7 @@ export function newConfig() { return; } - const mergedConfig = Object.keys(obj).reduce((accum, key) => { - const prevConf = _getConfig()[key] || {}; - accum[key] = mergeDeep(prevConf, obj[key]); - return accum; - }, {}); + const mergedConfig = mergeDeep(_getConfig(), obj); setConfig({ ...mergedConfig }); return mergedConfig; diff --git a/test/spec/config_spec.js b/test/spec/config_spec.js index 294fce2fa9b..d7f6b9de6c0 100644 --- a/test/spec/config_spec.js +++ b/test/spec/config_spec.js @@ -596,6 +596,7 @@ describe('config API', function () { } setConfig({ + bidderTimeout: 2000, ortb2: { user: { data: [userObj1, userObj2] @@ -609,6 +610,7 @@ describe('config API', function () { }); const rtd = { + bidderTimeout: 3000, ortb2: { user: { data: [userObj1] @@ -623,11 +625,13 @@ describe('config API', function () { mergeConfig(rtd); let ortb2Config = getConfig('ortb2'); + let bidderTimeout = getConfig('bidderTimeout'); expect(ortb2Config.user.data).to.deep.include.members([userObj1, userObj2]); expect(ortb2Config.site.content.data).to.deep.include.members([siteObj1]); expect(ortb2Config.user.data).to.have.lengthOf(2); expect(ortb2Config.site.content.data).to.have.lengthOf(1); + expect(bidderTimeout).to.equal(3000); }); it('should not corrupt global configuration with bidder configuration', () => {