Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29760565: Issue 6599 - Detect data corruption of storage.local (Closed)

Created:
April 24, 2018, 11:02 a.m. by Sebastian Noack
Modified:
April 27, 2018, 5:22 p.m.
Reviewers:
Thomas Greiner, kzar
Visibility:
Public.

Description

Issue 6599 - Detect data corruption of storage.local

Patch Set 1 #

Total comments: 3

Patch Set 2 : Detect when writing to storage.local fails but reading succeed #

Patch Set 3 : Removed redundant Promise wrapper #

Total comments: 14

Patch Set 4 : Rebased #

Patch Set 5 : Added comments, show uninstall page also when data corruption occurred #

Patch Set 6 : Added dataCorrupted parameter to uninstall page #

Total comments: 9

Patch Set 7 : Rebased #

Patch Set 8 : Fixed typos in comment #

Patch Set 9 : Made reinitialized and dataCorrupted a getter #

Patch Set 10 : Updated adblockplusui #

Patch Set 11 : Fixed circular dependency #

Total comments: 26

Patch Set 12 : Added comment, fixed typo #

Patch Set 13 : Added missing semicolon, made customSave logic respond asynchrnously #

Total comments: 2

Patch Set 14 : Fixed blocked_total optimization logic #

Unified diffs Side-by-side diffs Delta from patch set Stats (+102 lines, -80 lines) Patch
M dependencies View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M lib/prefs.js View 1 2 3 4 5 6 7 8 9 10 11 12 13 5 chunks +42 lines, -37 lines 0 comments Download
M lib/subscriptionInit.js View 1 2 3 4 5 6 7 8 9 10 11 12 4 chunks +47 lines, -32 lines 0 comments Download
M lib/uninstall.js View 1 2 3 4 5 6 7 8 2 chunks +12 lines, -10 lines 0 comments Download

Messages

Total messages: 27
kzar
I guess to test this we could override parts of the chrome.storage API to throw ...
April 24, 2018, 11:18 a.m. (2018-04-24 11:18:01 UTC) #1
Sebastian Noack
On 2018/04/24 11:18:01, kzar wrote: > I guess to test this we could override parts ...
April 24, 2018, 11:26 a.m. (2018-04-24 11:26:26 UTC) #2
kzar
Otherwise the approach and changes themselves LGTM https://codereview.adblockplus.org/29760565/diff/29760566/lib/subscriptionInit.js File lib/subscriptionInit.js (right): https://codereview.adblockplus.org/29760565/diff/29760566/lib/subscriptionInit.js#newcode244 lib/subscriptionInit.js:244: if (firstRun ...
April 24, 2018, 1:34 p.m. (2018-04-24 13:34:00 UTC) #3
Sebastian Noack
On 2018/04/24 11:18:01, kzar wrote: > I guess to test this we could override parts ...
April 24, 2018, 2:36 p.m. (2018-04-24 14:36:07 UTC) #4
kzar
I think the approach looks pretty good, handling both if the preferences fail to load ...
April 24, 2018, 4:18 p.m. (2018-04-24 16:18:46 UTC) #5
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29760664/lib/prefs.js File lib/prefs.js (left): https://codereview.adblockplus.org/29760565/diff/29760664/lib/prefs.js#oldcode264 lib/prefs.js:264: ext.storage.set(prefToKey(pref), overrides[pref]); On 2018/04/24 16:18:46, kzar wrote: > As ...
April 24, 2018, 5:49 p.m. (2018-04-24 17:49:26 UTC) #6
Sebastian Noack
On 2018/04/24 16:18:46, kzar wrote: > But I wonder if we should > also attempt ...
April 24, 2018, 6:17 p.m. (2018-04-24 18:17:41 UTC) #7
kzar
LGTM once the adblockplusui changes are included too. > So far it's not even certain ...
April 25, 2018, 10:53 a.m. (2018-04-25 10:53:51 UTC) #8
kzar
https://codereview.adblockplus.org/29760565/diff/29760664/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29760664/lib/prefs.js#newcode345 lib/prefs.js:345: overrides[keyToPref(key)] = items[key]; On 2018/04/25 10:53:51, kzar wrote: > ...
April 25, 2018, 10:59 a.m. (2018-04-25 10:59:07 UTC) #9
Sebastian Noack
As you suggested earlier, and data now approved, I added a dataCorrupted parameter to the ...
April 25, 2018, 1:20 p.m. (2018-04-25 13:20:01 UTC) #10
kzar
https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js File lib/subscriptionInit.js (right): https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js#newcode293 lib/subscriptionInit.js:293: exports.dataCorrupted = false; I just realised that this should ...
April 25, 2018, 2:38 p.m. (2018-04-25 14:38:12 UTC) #11
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js File lib/subscriptionInit.js (right): https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js#newcode293 lib/subscriptionInit.js:293: exports.dataCorrupted = false; On 2018/04/25 14:38:12, kzar wrote: > ...
April 25, 2018, 2:46 p.m. (2018-04-25 14:46:24 UTC) #12
kzar
https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js File lib/subscriptionInit.js (right): https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js#newcode293 lib/subscriptionInit.js:293: exports.dataCorrupted = false; On 2018/04/25 14:46:23, Sebastian Noack wrote: ...
April 25, 2018, 2:57 p.m. (2018-04-25 14:57:05 UTC) #13
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js File lib/subscriptionInit.js (right): https://codereview.adblockplus.org/29760565/diff/29761558/lib/subscriptionInit.js#newcode293 lib/subscriptionInit.js:293: exports.dataCorrupted = false; On 2018/04/25 14:57:04, kzar wrote: > ...
April 25, 2018, 5:08 p.m. (2018-04-25 17:08:56 UTC) #14
kzar
Thanks, LGTM once the adblockplusui changes are in.
April 25, 2018, 5:17 p.m. (2018-04-25 17:17:31 UTC) #15
Thomas Greiner
On 2018/04/25 17:17:31, kzar wrote: > Thanks, LGTM once the adblockplusui changes are in. FYI: ...
April 26, 2018, 4:10 p.m. (2018-04-26 16:10:49 UTC) #16
Sebastian Noack
On 2018/04/26 16:10:49, Thomas Greiner wrote: > FYI: The UI change has landed: > https://hg.adblockplus.org/adblockplusui/rev/8c49749e63e7 ...
April 26, 2018, 6:01 p.m. (2018-04-26 18:01:02 UTC) #17
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29762702/lib/subscriptionInit.js File lib/subscriptionInit.js (right): https://codereview.adblockplus.org/29760565/diff/29762702/lib/subscriptionInit.js#newcode277 lib/subscriptionInit.js:277: .then(() => { require("./uninstall").setUninstallURL() }) I found an issue ...
April 26, 2018, 6:25 p.m. (2018-04-26 18:25:35 UTC) #18
Thomas Greiner
Mostly suggestions and promise-related comments. https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js#newcode229 lib/prefs.js:229: throw new Error("Attempt to ...
April 27, 2018, 2:50 p.m. (2018-04-27 14:50:13 UTC) #19
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js#newcode229 lib/prefs.js:229: throw new Error("Attempt to change preference type"); On 2018/04/27 ...
April 27, 2018, 4:01 p.m. (2018-04-27 16:01:04 UTC) #20
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js#newcode319 lib/prefs.js:319: callback(); On 2018/04/27 16:01:04, Sebastian Noack wrote: > On ...
April 27, 2018, 4:14 p.m. (2018-04-27 16:14:53 UTC) #21
Thomas Greiner
Only one more comment to tackle and we'll be good to go. https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js File lib/prefs.js ...
April 27, 2018, 4:27 p.m. (2018-04-27 16:27:34 UTC) #22
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js#newcode229 lib/prefs.js:229: throw new Error("Attempt to change preference type"); On 2018/04/27 ...
April 27, 2018, 4:33 p.m. (2018-04-27 16:33:23 UTC) #23
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29763867/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29763867/lib/prefs.js#newcode310 lib/prefs.js:310: promise = null; Since callback() were potentially called synchronously ...
April 27, 2018, 4:58 p.m. (2018-04-27 16:58:58 UTC) #24
Thomas Greiner
https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js#newcode229 lib/prefs.js:229: throw new Error("Attempt to change preference type"); On 2018/04/27 ...
April 27, 2018, 5:03 p.m. (2018-04-27 17:03:33 UTC) #25
Sebastian Noack
https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js File lib/prefs.js (right): https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js#newcode229 lib/prefs.js:229: throw new Error("Attempt to change preference type"); On 2018/04/27 ...
April 27, 2018, 5:11 p.m. (2018-04-27 17:11:12 UTC) #26
Thomas Greiner
April 27, 2018, 5:16 p.m. (2018-04-27 17:16:07 UTC) #27
LGTM

https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js
File lib/prefs.js (right):

https://codereview.adblockplus.org/29760565/diff/29762702/lib/prefs.js#newcod...
lib/prefs.js:229: throw new Error("Attempt to change preference type");
On 2018/04/27 17:11:11, Sebastian Noack wrote:
> Yes, we could signal the error asynchronously here and redundantly check in
the
> setter to signal it synchronously there, but this will involve some
(undesired)
> duplication. And again, I think it is totally fine if any calling code just
> handles the promise rejection and ignores the error thrown here. It's just an
> assertion, to avoid accidentally assigning a value of the wrong type, during
> development. If this error is ever thrown, the code that triggers it should be
> changed rather than handling that error.

Note that assertions may fail asynchronously in which case such errors could
occur not only during development but also in production. So while I'm not happy
about ignoring errors, I can understand it since that appears to be a convention
here.

Powered by Google App Engine
This is Rietveld