Open Bug 1937098 Opened 1 year ago Updated 21 days ago

Profile contains an empty XPI file after an add-on update

Categories

(Toolkit :: Add-ons Manager, defect, P3)

defect

Tracking

()

People

(Reporter: willdurand, Unassigned)

References

Details

I've investigated an internal bug report yesterday where the user had an add-on installed and apparently enabled, but it wasn't working. The extension could not be located in the Firefox UI (nav-bar or extensions panel), and it wasn't listed in about:debugging either. That being said, the extension was listed in about:addons (as enabled, without any error/warning message) and in about:support (marked as enabled too). The extensions process was also running (in about:processes).

Some browser console logs highlighted an error during startup (by disabling then re-enabling the extension). The error was thrown at https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/toolkit/components/extensions/Extension.sys.mjs#1164

Therefore, I asked the user for the checksum of the file and it wasn't the expected one. The user confirmed that the file was different than the same XPI downloaded from AMO separately. We then noticed that the XPI file in the user's profile was empty.

The user uses Firefox for desktop on Linux. Luca and I looked into how we could end up with an XPI file that is empty, despite the use of a SafeInstallOperation instance. In fact, this class is interesting for two reasons:

  1. It uses nsIFile.copyTo() or nsIFile.moveTo().
  2. When the call to moveTo() throws, we catch the error and then we re-throw it: https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/toolkit/mozapps/extensions/internal/XPIInstall.sys.mjs#1144,1147-1156

The current theory is therefore that the add-on was updated incorrectly. The download of the XPI went well, the integrity check on the file was fine, the signature check was also fine. All of this seems to happen in the staged directory. After that, the file was moved from the staged directory to the extensions/ one, and that's when the XPI file became an empty file. As for the rest, the metadata/xpi database was correctly updated because that's pulled from AMO and/or updated before we moved the file to the extensions/ directory. That's why the add-on "looks" enabled in about:addons.

The Bugbug bot thinks this bug should belong to the 'Toolkit::Add-ons Manager' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Add-ons Manager
Product: WebExtensions → Toolkit

I've seen this kind of issue before (more than once!), e.g. bug 1670149.

Since we has looked into this and this is relatively fresh, perhaps it would be good to take a look at a patch at the start of the new year.

See Also: → 1670149

The severity field is not set for this bug.
:rpl, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(lgreco)

(clearing needinfo, to be triaged at the next meeting)

Flags: needinfo?(lgreco)
Severity: -- → S4
Priority: -- → P3

I'm seeing something similar to this happen again just now, where, despite Bug 1639163 having been fixed a few months ago, the \extensions\trash folder in my Firefox profile currently contains an xpi (not empty) from what I believe was an automated, possibly deferred, update attempt of the extension that must have failed, which is now blocking further automated and manual update attempts of that extension, unless the browser is restarted.

Each time Firefox checks for updates in the background for this extension, it tries and fails to extract the downloaded xpi to update it (because the trash folder item remains in the way), and then the extension gets removed from the address bar, exactly as described above, effectively deactivating it, but where it still shows up as enabled under "Manage your extensions".

Just a theory, but maybe the fix for Bug 1639163 was incomplete, and it also needs to include a clearing of such trash items whenever an automated update of an extension fails for whatever reason, and whenever a subsequent manual update (even from file) is initiated?

You can see my comments from a few months ago on Bug 1627495, which it now looks like the fix of Bug 1639163 has apparently not resolved: https://bugzilla.mozilla.org/show_bug.cgi?id=1627495#c38

You need to log in before you can comment on or make changes to this bug.