You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but the event is never fired because the JS API runtime.onInstalled.addListener has to be called synchronously in the background script. And because WASM is asynchronously loaded, the execution of the web-extensions-sys wrapper is called too late
importinitfrom'./pkg/background.js';// here we have to call runtime.onInstalled.addListenerinit().then(()=>{// but it's called by the WASM module here}).catch(console.error)
There is a method that can init the module synchronously but the fetch is still asynchronous:
// in service worker
var promise = WebAssembly.instantiateStreaming(......);
async function onInstall() {
let obj = await promise;
// use obj
}
chrome.runtime.onInstalled.addListener(onInstall);
That makes it seem like the answer is "you can't do it", and it can really only be improved slightly from where we are now.
Adding a event listener with
but the event is never fired because the JS API
runtime.onInstalled.addListener
has to be called synchronously in the background script. And because WASM is asynchronously loaded, the execution of theweb-extensions-sys
wrapper is called too lateThere is a method that can init the module synchronously but the
fetch
is still asynchronous:So does anybody have an idea how to solve this problem?
The text was updated successfully, but these errors were encountered: