In Edge Extension, one of typical infrastructures is using Centennial to package three parts (Scripts and Content loaded by Edge, UWP run as App Service for receiving commands from Edge and pass them to backend and vise versa, backend is run as a Win32 app (Desktop Bridge Component) which executes some hard core tasks. You can get more details from this sample project:
In case UWP App Service is stopped for some reason, but Edge is still open, the Edge Extension better to consider a proper re-try mechanism to resume its app service tasks. Here are two methods to solve this from Code ( Use the above SecureInput as a sample).
In /SecureInput/Extension/content.js, it uses browser.runtime.sendMessage to send message to background.js:
In /SecureInput/Extension/background.js, it calls sendResponse method to send message to UWP App Service, if any exception throwed by sendNativeMessage (including app service is turned down), it has chances to send response back to the Content.js with success ‘false’ field:
Then we can modify content.js to check the success field, if it is false, we can do re-connect:
the connectNativeApp in content.js will finally call connect in Background.js:
This will work.
Another thought is in background.js, it has one onDisconnected call back when App Service is turned down, you can also handle this call back to do re-connect. In the real situation, we used the first method and it works. The second one cannot always work in Windows fast startup situation.