In this previous post, I showed how to implement a Chrome Browser extension to talk to a native app on user local machine. Recently, we added support for Microsoft Edge browser and published to Microsoft Edge Add-ons store.
We then received reports from some testers in the team that the Edge extension does not work for them. When the application sends message to the extension and the extension tries to send it to the native app on the local machine, it fails and comes back with the following error.
Unchecked runtime.lastError: The message port closed before a response was received
This error is actually quite generic and it can be due to many different problems. After a lot of research, I got the testers to show me if they have any errors in the background page console and this was what they sent me.
"allowed_origins": [
"chrome-extension://{Google Chrome Extension ID}/",
"chrome-extension://{Microsoft Edge Extension ID}/" // added to list of allowed extensions
]
The reason only some people had this issue was that we had an updated installer for the native app which automatically adds the new Microsoft Edge extension ID to the allowed origins but they did not run it and so the older version of the native host config json file only had Google Chrome extension ID.