Re: [w3ctag/design-reviews] Extended lifetime shared workers (Issue #1089)

lolaodelola left a comment (w3ctag/design-reviews#1089)

Hi @domenic, the TAG discussed this proposal and are unsure whether the benefits outweigh the risks of making other issues worse (for example [unnecessarily long lifetimes](https://github.com/whatwg/html/issues/10997#issuecomment-2647971813), from [@annevk](https://github.com/annevk), and [WebLock-based hangs](https://github.com/whatwg/html/issues/10997#issuecomment-3105509844) from [@fergald](https://github.com/fergald)). We are also concerned that we did not see an idiomatic solution with a complexity matching the scope of the use case ( without introducing a whole new complicated mechanism). The current proposal starts the SharedWorker when it’s ready to do some work, however we feel there’s need for some pre-mediation work to setup the worker without the unbounded shape:

 ```js
// Create a transferable item that encapsulates the state that needs to be cleaned up
// if the page closes before the regular process has a chance to do that work.
let item = { ... }; 
// Could be `using` when https://github.com/tc39/proposal-explicit-resource-management is ready.
let h = await SharedWorker.runCleanupOnExit(url, item);

// ...Later
// If the work completes successfully.
h.cancel();
```

The process to register intent to extend should be tied to activity on-page that precedes closing of the window/tab. The item is dispatched as an extendable event to the SharedWorker instance when the page exits, and the associated promise should have enough time to resolve between user actions, except in the case where the closing of the window is the action that needs to be saved.

Thanks for having us to discuss this issue! We are closing it for now, but feel free to reopen if you have updates to the proposal.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/1089#issuecomment-3223509858
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/1089/3223509858@github.com>

Received on Tuesday, 26 August 2025 10:07:02 UTC