”Unable to parse JSON data for extension storage” error for a webextension installation

VERIFIED FIXED in Firefox 50


3 years ago
Last year


(Reporter: vasilica.mihasca, Assigned: freaktechnik, Mentored)



Firefox Tracking Flags

(firefox45 affected, firefox46 affected, firefox47 unaffected, firefox48 affected, firefox49 affected, firefox50 verified)


(Whiteboard: [good first bug]triaged)


(1 attachment, 1 obsolete attachment)

This is a follow-up bug for Bug 1197475

[Affected versions]:
Firefox 48.0a1 (2016-04-17)
Firefox 46.0b11 
Firefox 45.0.2

[Affected platforms]:
Windows 10 64-bit
Ubuntu 14.04 32-bit
Mac OS X 10.11

[Steps to reproduce]:
1.Launch Firefox with clean profile.
2.Create the xpinstall.signatures.dev-root pref in about:config and set it to true.
3.Install the following webextension:  https://addons.allizom.org/en-US/firefox/addon/testwebextension/?src=ss
4.Check the Browser Console.

[Expected Results]:
There are no errors thrown in Browser Console.

[Actual Results]:
The following JS error appears after installing the webextension: Unable to parse JSON data for extension storage. ExtensionStorage.jsm:49:0

[Additional notes]:
- I am marking Firefox 47.0a2 (2016-04-17) as unaffected because the webextension cannot be installed on this Firefox version.
- I was able to reproduce this issue down to Firefox 42.
I think this is a harmless error that just happens because we don't have a special case to handle when the file doesn't yet exist:


So we just need to check if OS.File.read throws an error because the file doesn't exist, and if so, treat it as success:

Mentor: kmaglione+bmo
Whiteboard: [good first bug]
Whiteboard: [good first bug] → [good first bug]triaged

I am new here, If this bug is still open I would like to work on this.
I tried to reproduce the scenario. What I did:
I am using Mozilla VM, I executed following steps:
1. Build the source code.
2. Run the Nightly version of firefox
3. Followed steps to reproduce and got the error as mentioned.

I want to debug more. I used console.log() to check the path variable that is being passed in OS.File.read() and flow but did not get any sccusses.

Looking for help to debug and fix this issue.
Flags: needinfo?(kmaglione+bmo)
Also, As I am new I do not have much idea what code is done. It would be great if you could give some pointers.
`console.log` isn't available in this context. You can use Services.console.logStringMessage to log a message to the console, dump() to log a message to the standard output, or the browser debugger[1] if you need to debug browser code.

[1]: https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox
Flags: needinfo?(kmaglione+bmo)
Posted patch bug1265317-v1.patch (obsolete) — Splinter Review
Fixes the error as suggested, by handling a missing file as success. After I applied this patch the error was gone.
Attachment #8762899 - Flags: review?(kmaglione+bmo)
Assignee: nobody → martin
Comment on attachment 8762899 [details] [diff] [review]

Review of attachment 8762899 [details] [diff] [review]:

::: toolkit/components/extensions/ExtensionStorage.jsm
@@ +103,5 @@
>      let promise = OS.File.read(path);
>      promise = promise.then(array => {
>        return JSON.parse(decoder.decode(array));
> +    }, (error) => {
> +      if (error instanceof OS.File.Error && error.becauseNoSuchFile) {

We can add this check to the existing `.catch()` handler. And there's no need for the `instanceof OS.File.Error` check. Just checking the `becauseNoSuchFile` property is enough.
Attachment #8762899 - Flags: review?(kmaglione+bmo)
Simplified the error handling as suggested.
Attachment #8762899 - Attachment is obsolete: true
Attachment #8762907 - Flags: review?(kmaglione+bmo)
Comment on attachment 8762907 [details] [diff] [review]

Review of attachment 8762907 [details] [diff] [review]:

Looks good. Thanks!
Attachment #8762907 - Flags: review?(kmaglione+bmo) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
Handle missing storage error as success. r=kmag
Keywords: checkin-needed
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
I was able to reproduce the initial issue on Firefox 48.0a1 (2016-04-18) under Windows 10 64-bit.

Verified as fixed on Firefox 50.01 (2016-06-26) under Windows 10 64-bit and Ubuntu 16.04 32-bit. The error is no longer thrown in Browser Console.
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.