Addon update in Firefox

Hello,

I would like to have some information about how addons are updated in Firefox. I designed an addon which has an important update between version N and N+1. I introduced a piece of code which is executed once only in order to convert old storage data from N to new data in N+1.

//background.js
browser.storage.local.get(function(storage){
    if(storage.version<N+1){
        /*********** Converting code ***********/
        /* browser.storage.local.set({ ... }); */
    }
});

Most users updated to version N+1 but some still use version N. Now I want to publish a version N+2 which doesn’t contain the converting code anymore.

[version N] --------------------> [N+1] --------------------> [N+2]
old storage ------------> converting code ---------> new storage
10% users -------------------> 90% users

My questions are :

  • Will the 10% users update to N+1 before N+2 ?
  • Do I need to keep the converting code in version N+2 and higher ?

I’m pretty sure you’ll have to keep the migration script.
Some users will turn on their old PC after few months and their add-ons get updated over X versions released in the meantime (so they may jump from version 1.0 to 9.9).

This is what I use:

const DATA_MIGRATION_PROMISE = browser.storage.local.get('hotfix_10_6').then(async dataHotfix => {
  if (dataHotfix.hotfix_10_6) return;   // hotfix already applied
  // add migration script here
  await browser.storage.local.set({hotfix_10_6: 1});
});

Then I await the promise somewhere in the main init function in the background script.

Not necessarily, as in, likely not. Depends on why they are still on N.

Possibly, as a result of not having any guaranteed upgrade path.

Thank you for this clarification. I assume that I need to keep this code in next versions until all users update their addon.