Reloading web extension duplicates context menu items

If I add a background script that adds a context menu item using chrome.contextMenus.create() that menu item will be created again every time the web extension gets auto reloaded by web-ext or if I manually reload it with the reload button in about:debugging.

How can I prevent this from happening? Is it a bug? I’ve tried calling chrome.contextMenus.removeAll() and chrome.contextMenus.remove('id') before I create any context menu items but the functions doesn’t remove any of the old menu items that were added on previous reloads.

It also seems like the click event for the menu item will only get called if I click the last menu item in the context menu but I suppose the reason for that is that they all have the same id?

I’m using Firefox Developer Edition 49.0a2 (2016-07-21) when I’m testing this.

Thanks!

I also reported such a bug long time ago. I was told to wait for FF48.

Did you report it here or was it on Bugzilla?

I can’t seem to find any reported bugs for this issue anywhere.

On Bugzilla … here is their final response:

I checked the add-on in Firefox 48 and 49, and it seemed to work as expected.
If you’re still seeing a problem, please file a bug.

It seems like this bug has already been fixed in Nightly: https://bugzilla.mozilla.org/show_bug.cgi?id=1288695