Latest Firefox Update broke add-on (sendMessage)

Started getting this after the Firefox 79.0 update and I don’t see what exactly in the change log could break this code:

import browser from "webextension-polyfill";

export const background_script_api = new Proxy(
  {},
  {
    get(target, command) {
      return (data) => browser.runtime.sendMessage({ command, data })
    },
  }
);

Throws:

Error: Conduits:RuntimeMessage: message reply cannot be cloned.
 get background-communicator.js:7

webextension-polyfill is a NO-OP when running in Firefox.
This error doesn’t happen in the previous version of Firefox, only in 79.0

I’ve also seen this error recently and I was also surprised why I didn’t noticed the issue before…
So maybe something did changed.

Anyway, in my case I was sending object that contained a Promise, which caused the issue. But there are other un-clonable types as well.

Simple fix could look like this:

JSON.parse(JSON.stringify(data))

I’m trying to find more info, but the docs are confusing.
For runtime.sendMessage it says the message is “An object that can be structured clone serialized.”.
For tabs.sendMessage it says the message is “An object that can be serialized to JSON.”.

It seems that passing undefined for a variable doesn’t work anymore and you have to pass something else (for example {}) instead:

browser.runtime.sendMessage({ data: data ?? {} });

Which is weird change that isn’t mentioned anywhere.

Still having a lot of other weird issues with sendMessage after changing to this code

sendRemoveListener on closed conduit ConduitsChild.jsm:108
Promise resolved after context unloaded
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.

What exactly is not working? Do you get the clone error?

Regarding the “Receiving end does not exist”, this happens when you send message somewhere, expecting a reply but there is no receiver registered which could reply.
This can happen if you for example create new tab and send there a message, but the tab is not yet fully loaded so you get this error.

Hey, thanks for reporting this @R4d1z! We’ve opened a bug for this issue.

2 Likes

I know what the error means, but this flow works perfectly in Firefox 78.x and Chrome, so the update introduced some changes as to how messaging works.

I’m not getting a clone error after the aforementioned changes in code.

1 Like

@R4d1z, could you provide the link to your extension and the steps to reproduce the issue, either here or on the bug? That will help us speed up the investigation.

I saw that an extension was already provided in the bug description. What does the “wontfix” tag mean, is this not an issue?

firefox79 	--- 	wontfix
firefox80 	--- 	affected
firefox81 	--- 	affected

It’s just for the current 79 version. Because it’s already been released.

1 Like

Hi I’ve just made a new post on exactly this subject went to ff79.0& everything just fell apart. No pages would load as kept getting the you are either not on the internet or the certificates are expired(which has me ready to go to the new edge or chrome as I can’t be without pages for days)anyway I got it working again by uninstalling79.0 then reinstalling it from Mozilla site just when it tells you it will probably be best for a fresh install I pressed no(after trying yes&getting nowhere)&it came back on with all extentions working &all bookmarks back. Could be a fluke but I never had1bit of trouble in the UK last year when FF was getting verbally battered by all it’s US users(as it should)then touchwood all been good for4days now,but I will not have it go off again IL be off to greener pastures