Error: Invalid call to runtime.connect(). No runtime.onConnect listeners found.

Hi, I am developing the Click & Read web add-on for Chromium, Firefox and Safari. We use xcrun safari-web-extension-converter tool to generate the Safari add-on. The build on Xcode had no meaning errors/warnings, until we had to switch to a more up-to-date MacBook (required as deprecated Mac had no support for latest macOS and thus for Xcode compatibility !).

So now I build my add-on on an Apple M1 MB Air on Sequoia 15.0 with latest Xcode, but I encounter an error ? or warning ? :

NSBundle file:///System/Library/PrivateFrameworks/MetalTools.framework/ principal class is nil because all fallbacks have failed
Unable to create bundle at URL ((null)): normalized URL null
Unable to create bundle at URL ((null)): normalized URL null
Unable to create bundle at URL ((null)): normalized URL null

But it doesn't prevent the add-on build to complete as I am able to open it onto Safari. Then, when loading the add-on on a test web page, I get this error on safari console:

Error: Invalid call to runtime.connect(). No runtime.onConnect listeners found.

BTW, the same add-on Dist works as expected on Chrome or Firefox (on macOS).

So it seems the runtime listener runtime.onConnect.addListener isn't initiated on Background script...

Thanks for your feedback and help

It's hard to know what is going on here without a bit more information.

Is it possible to file feedback on https://feedbackassistant.apple.com with a sample project that reproduces this issue and steps to how you did reproduce it?

Thanks!

Can you test in the latest version of Safari Technology Preview (https://developer.apple.com/safari/technology-preview/) - I expect it to be fixed there.

Hi, Thanks for your support.

in order to be clearer, I'll give more accurate info:

  • Our add-on project web site (only usage and install doc): https://clickandread.inist.fr
  • The command I use to trigger a build with Xcrun:

xcrun safari-web-extension-converter --app-name "Click and Read" --bundle-identifier fr.inist.Click-and-read --swift --force --macos-only dist

  • Once the safari converter having launched Xcode with the generated project, I click on play to build this project. Then I get the add-on app built (with some errors ?) ready to be opened and activated in Safari.

  • Once my add-on enabled and set, I browse on a dedicated testing page, which should be injected with add-on content script (to display some C&R green buttons on the page).

  • Unfortunately, either on LTS or Preview Safari, I get the same error in console...

Please see attached screenshots.

I don't see why the runtime.onConnect event listener cannot be found. According to my code in background script, it should be initialised:

// Listener on sent parsed ID list from content script to be resolved
currentBrowser.runtime.onConnect.addListener((port) => {
  port?.onMessage.addListener(async ({ parsedIdList }) => {
    if (parsedIdList?.length > 0) {
      // some logic here
    }
  });
});

Thank you for all of this updated information! If it's not too much trouble, can you put it in a bug report for us at https://feedbackassistant.apple.com and include the feedback ID in here after filing?

Thanks!

Error: Invalid call to runtime.connect(). No runtime.onConnect listeners found.
 
 
Q