Web-ext: browser.downloads.erase doesn't work

Manjaro Linux
Firefox 81.0 (64 bit)

I’ve attached a test extesion that downloads a file (stored inside the extension) to the default downloads directory.
When the file has finished downloading, the extension first deletes the file from disk, and then removes the file from the download history.
(because you’re supposed to do it in that order, according to the API docs)

If I load the extension with
about:debugging > This Firefox > Load Temporary add-on
everything works fine.

But if I run the extension with
web-ext run
the file remains in the download history.
Under the file name in the download history, there’s an error message: “File moved, renamed or deleted”
The file does get deleted from disk, however.

What am I doing wrong?

removefile.zip (4.6 KB)
2020-10-03_Remove_File

Given that I can not even reproduce your issue with web-ext and Firefox Nightly, I’d recommend looking at it with a debugger. See https://extensionworkshop.com/documentation/develop/debugging/ for guidance on how to get to the debugger. To test the specific case of your reduced extension with a debugger, you’d likely want to add some sort of trigger instead of immediately executing when the extension loads.

I’ve attached a new version that downloads the test file when you click on the browser action.
The test files now have numbers: Test_1.txt, Test_2.txt, etc.
I’ve done this to rule out the possibility that using the same filename, and therefore potentially overwriting an existing file, somehow causes problems.

If I load the extension with
about:debugging > This Firefox > Load Temporary add-on
everything works fine, as before.

If I use
web-ext run
the file remains in the download history.
But:
If I then click the browser action again, the old file is removed from the download history, and only the new file is now in the download history.
And if I click the browser action multiple times in quick succession, all files disappear from the download history.
After that, the extension works like it should: When I click once on the browser action, the file is both removed from disk and from the download history.

I’ve also set breakpoints in two places:
browser.downloads.removeFile(downloadItems[0].id)
browser.downloads.erase({id: downloadItems[0].id})

But that didn’t change the outcome in any way.

I’ve also tried the Firefox 81.0b9 (64-Bit)
(currently the newest developer edition on Manjaro)
Exactly the same bug.

Since you can’t reproduce the bug, it’s most likely a problem with Manjaro.
I’ll either report it to the Manjaro or the web-ext developers.

removefile.zip (4.7 KB)