discoverAnkit
discoverAnkit

Reputation: 1151

Firefox Extension : Unable to parse JSON data for extension storage

I have written a Firefox Extension using Web Extension APIs. It has passed the Preliminary review but the reviewer said that he cannot proceed with the full review cause when he installs it, he gets the following error -

"Unable to parse JSON data for extension storage"

Upon inspecting for quite sometime, I figured that Firefox creates a file called "storage.js" in the profile folder for each extension where it writes and reads from, all the local storage data for that particular extension. And if the extension tries to write to this file before this file is created, the error "Unable to write JSON data to extension storage" is thrown and if the extension code tries to read from this file before this file is created, the error "Unable to parse JSON data for extension storage" is thrown.

Now, my concern is how do I know for sure that the file has been created and that it can be written to or read from?

PS : This happens when the extension is just installed. For consequent sessions, this error wont come as that file is no longer missing.

Upvotes: 3

Views: 743

Answers (1)

nmaier
nmaier

Reputation: 33162

This seems to be a bug in the current Firefox implementation, and your assessment is spot on:

  • The underlying ExtStorage module will always call read before get, set etc. even write and clear.
  • read will unconditionally try to access the underlying, extension specific storage file, that may not exist yet for freshly installed add-ons using the storage API for the first time.
  • This will therefore result in the logging of one such Unable to parse JSON data for extension storage message, no matter what you do with the storage API.
  • Therefore triggering the message cannot be avoided.

I suggest you do the following:

  • Contact the editors team, requesting they re-evaluate your add-on based on:
    • The message in question is really only a warning (when appearing after first access of the storage API by your addon).
    • Even when the message would be an actual error (the storage is corrupt), it would still not be your error, as the storage API implementation by mozilla needs to be more resilient then and there is nothing you can do anyway.
    • The message being issued on first regular use of the storage API, unrelated to what WebExtensions add-on uses that API and in what way, is a mozilla bug, and not something you caused or can fix yourself or at least work around.
    • Therefore denying a full review just because a mozilla bug erroneously logs a spurious message once without any other severe effects is... questionable.
  • File a bug about this so mozilla developers can address this issue. You'll wanna CC at least Bill McCloskey (:billm) since he wrote that code ;)

Upvotes: 3

Related Questions