Registering onInstalled handler from WASM

Skip to first unread message

Liam Bowen

Sep 28, 2022, 9:58:10 AMSep 28
to Chromium Extensions
I'm building an extension whose service worker is written in WASM with Rust. It has been a good experience so far. There are only a few lines of JS in the worker, and those lines just load the WASM asynchronously. It could be loaded semi-synchronously, by which I mean that the loading could be synchronous except that the WASM file has to be retrieved via fetch(), which would make it miss the first iteration of the event loop, and therefore wouldn't be really synchronous.

I've read this in this group in other posts, which seems to be accurate based on my tests: "The `addListener` must be called synchronously in the first iteration of the event loop."

Is there any way that I can use WASM to handle the onInstalled event?

Thanks in advance!

Jackie Han

Sep 28, 2022, 10:43:33 AMSep 28
to Liam Bowen, Chromium Extensions
// in service worker
var promise = WebAssembly.instantiateStreaming(......);
async function onInstall() {
  let obj = await promise;
  // use obj 

You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages