How does the chrome.runtime.sendMessage work?

Hello,

I am loading chrome extensions into my electron application. A lot of extensions use the “chrome.runtime.sendMessage” (and related) API to exchange messages between the different scripts.

I have implemented a popup (“browser action”) mechanism for the extension, however the messages exchanged between the parts of the extension do not succeed and give an error message of “Error: Could not establish connection. Receiving end does not exist.”.

How can I “connect” the parts of the extension?

On https://www.electronjs.org/docs/api/extensions, the docs mention that this API is suppositely implemented, but I can’t find any additional information on that and how I can register the receiving end.