Re: [w3c/ServiceWorker] Support `close()` method in ServiceWorkerGlobalScope (Issue #1696)

I think one possible motivation is that close() would be a massive foot-gun. A service worker can be processing many different ExtendableEvents at the same time, and without manual bookkeeping there isn't really a way for a service worker script to know what events are in progress. If close() would immediately terminate the service worker all these events would get aborted or something, which probably is rarely the behavior intended. On the other hand if close() would wait for all extendable events to finish first it might not fulfill the stated goals/use cases either, as it could take arbitrarily long for that to be true.
I suppose the same is somewhat true for dedicated/shared worker close(), although there the only thing that can trigger something to happen in the worker is an explicit postMessage by website code, while in service workers there are many external/user agent initiated things that can also trigger events etc.

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

Message ID: <w3c/ServiceWorker/issues/1696/1787549292@github.com>

Received on Tuesday, 31 October 2023 16:19:09 UTC