From d37ce0ce0443765b5f1ce31603e22548a75fbca3 Mon Sep 17 00:00:00 2001 From: yan Date: Tue, 13 Jun 2017 15:43:37 -0700 Subject: [PATCH] do not error if createSiteData cannot build a siteKey fix https://github.com/brave/browser-laptop/issues/9430 Test Plan: 1. enable sync 2. visit https://www.google.com/#q=test 3. enable the setting to clear browsing history when Brave is closed in about:preferences#security 4. close and restart Brave 5. you should see 'Ignoring entry because we can't create site key' in the console but no errors --- js/state/syncUtil.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/state/syncUtil.js b/js/state/syncUtil.js index 1f3a459032c..9dca82d3c9a 100644 --- a/js/state/syncUtil.js +++ b/js/state/syncUtil.js @@ -481,7 +481,10 @@ module.exports.createSiteData = (site, appState) => { const immutableSite = Immutable.fromJS(site) const siteKey = siteUtil.getSiteKey(immutableSite) || siteUtil.getSiteKey(Immutable.fromJS(siteData)) if (siteKey === null) { - throw new Error('Sync could not create siteKey') + // May happen if this is called before the appStore object has its location + // field populated + console.log(`Ignoring entry because we can't create site key: ${JSON.stringify(site)}`) + return } if (module.exports.isSyncable('bookmark', immutableSite)) { const objectId = site.objectId || module.exports.newObjectId(['sites', siteKey])