Re: [w3c/ServiceWorker] Top-level await integration for ServiceWorkers running modules (#1407)

For TPAC:

**Thoughts:**

No one allows modules in service workers yet.

Developers may end up doing things like awaiting state from IDB on each service worker load. The worst gotchas would be async things that are *sometimes* very slow, but may not show up in dev due to different conditions.

However, developers can currently spin a while loop for seconds as part of service worker start up, and we haven't lost too much sleep over that. Similar things might happen when importing large libraries that do a lot of setup work.

We haven't blocked a JS feature in service worker before. Although, we did block XHR, partially because of sync XHR.

**Option 1:** Allow top level `await` as is. Service worker initialisation would be blocked on the main script fully executing, including `await`ed content.  We'd advocate against it using it, and perhaps fire warnings in devtools.

**Option 2:** Ban it. The service worker would throw on `await`, so it wouldn't install.

**Option 3:** Allow top level `await`, but the service worker is considered ready once execution + microtasks are done. That means the `await`s will continue to run, but events may be called before the script has 'completed'. Adding events after execution + microtasks is not allowed, as currently defined.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1407#issuecomment-531540679

Received on Sunday, 15 September 2019 07:05:01 UTC