- From: Domenic Denicola <notifications@github.com>
- Date: Wed, 27 Aug 2025 18:08:35 -0700
- To: w3ctag/design-reviews <design-reviews@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3ctag/design-reviews/issues/1089/3230727035@github.com>
domenic left a comment (w3ctag/design-reviews#1089) I think it's making a bit more sense, but it still seems like it's syntactic sugar for the existing proposal. That is, you can reproduce what you're proposing in the following manner: ```js // In the main document const controller = new AbortController(); document.addEventListener("pagehide", () => { const worker = new SharedWorker(url, { extendedLifetime: true }); worker.postMessage({ runCleanupOrExitUsingThisData: item }); }, { signal: controller.signal }); // If later we decide we don't need to run cleanup or exit: controller.abort(); ``` ```js // In the worker: self.addEventListener("message", async e => { const data = e.data.runCleanupOrExitUsingThisData; try { await runCleanupOrExit(e); } finally { self.close(); } }); ``` From what I can tell, the differences between the above and `SharedWorker.runCleanupOnExit()` are: - `SharedWorker.runCleanupOnExit()` serializes (but does not deserialize) the data ahead of time. This uses the user's CPU time earlier, which might be good if it shifts work away from the busy time of unloading the document, but might be bad if we later decide we don't need to run cleanup or exit. - `SharedWorker.runCleanupOnExit()` uses `ExtendableEvent`s so that it automatically closes the shared worker, instead of relying on `finally { self.close(); }` - However, the browser can clean up the shared worker (even the extended lifetime shared worker) automatically if it is not performing any async work, so, I'm not sure this is a real advantage. That is, neither the `ExtendableEvent` complexity nor the `finally { self.close(); }` code are really necessary. Are there other differences I might be missing? -- Reply to this email directly or view it on GitHub: https://github.com/w3ctag/design-reviews/issues/1089#issuecomment-3230727035 You are receiving this because you are subscribed to this thread. Message ID: <w3ctag/design-reviews/issues/1089/3230727035@github.com>
Received on Thursday, 28 August 2025 01:08:44 UTC