Repository navigation
Description
Description
With SharedWorker support being added to Chromium for Android 148, SharedWorkers have become a viable option for instantiating costly resources once per origin. Examples include WASM modules, SSE/WebSocket connections, in-memory search indexes, etc...
A challenge, however, is that SharedWorkers' lifetime is often shorter than expected.
Chromium 148 added a new extendedLifetime: true option for the SharedWorker constructor that keeps the worker alive briefly after its last client unloads, so pages can finish async work on unload (e.g. IndexedDB writes, encrypt/compress-then-fetch) without needing a service worker.
Another significant use-case that was not discussed much previously is when only one tab is open for the origin, thus the SharedWorker unloads and reloads every time you make any full-page navigation - which can be very unnecessarily costly depending on what the SharedWorker is doing. This is particularly prevalent in a PWA context, which realistically only ever has a single tab open. So, if the PWA is an MPA, every navigation re-instantiates the SharedWorker. In that sense, extendedLifetime reduces the need for more complicated SPA architectures.
const worker = new SharedWorker("worker.js", { extendedLifetime: true });The lifetime is capped at the existing service-worker no-client lifetime — no new background-execution capability, just parity with service workers. See theexplainer and origin trial write-up for background.
A spec has already been written for this, so it would be fantastic if support could be made universal.
Relevant discussions:
- A new API for work during unload whatwg/html#10997
- Add extended lifetime shared workers whatwg/html#11600
- What should be the interaction between SharedWorkers and inactive documents whatwg/html#11520
Specification
- WHATWG HTML:
SharedWorkerOptions.extendedLifetime - spec PR whatwg/html#11600 (merged 2026-03-06)
web-feature
shared-workers
Note for the triage bot: api.SharedWorker.SharedWorker.options_extendedLifetime_parameter is in BCD but is not currently listed in the shared-workers web-feature's compat_features, so the auto-generated status summary may not reflect this sub-feature.
Test Links
Promoted out of tentative/ in April 2026; all run in Chrome, Edge, Firefox and Safari desktop runs. Aggregate: https://wpt.fyi/results/workers?q=extendedLifetime
- SharedWorker-extendedLifetime.html
- SharedWorker-extendedLifetime-blob.html
- SharedWorker-extendedLifetime-data.html
- SharedWorker-extendedLifetime-named-module.html
- shared-worker-options-mismatch.html (8 new
extendedLifetimemismatch subtests)
Current results (master @ 92054a74d0, 2026-09-08):
| Test | Chrome 155 | Edge 154 | Firefox 157 | Safari 251 preview |
|---|---|---|---|---|
SharedWorker-extendedLifetime.html |
pass | pass | fail | fail |
...-blob.html |
pass | pass | pass | pass |
...-data.html |
pass | pass | pass | pass |
...-named-module.html |
2/2 | 2/2 | 0/2 | 0/2 |
shared-worker-options-mismatch.html |
32/32 | 32/32 | 24/32 | 24/32 |
The 8 mismatch failures in Firefox and Safari are exactly the new extendedLifetime mismatch subtests, which is consistent with the option not being implemented (an unrecognised dictionary member is silently ignored rather than causing a mismatch error). I would flag that the current coverage is thin and mostly a single behavioural scenario; I expect the focus area to need additional tests, for example around name/URL identity, reconnection to a worker with zero clients, close(), and the bfcache cases that #11520 leaves open.
Additional Signals
Standards positions:
- Mozilla positive
- WebKit open, opposition proposed (OT results from 35 origins posted Apr 2026, no reply since)
- TAG unsatisfied (fixed-timeout footgun / Web Locks concerns; counter-proposal discussed in the thread)
Current state:
- Chrome: Shipped in148 (desktop/Android/WebView, chromestatus)
- Firefox/Safari unimplemented per BCD
- documented in mdn/content#43955 (tracking: mdn/mdn#812).
Browser bugs:
Workaround:
- sites register a service worker purely to run async code after unload (persistent registration, disk, resident process, separate same-origin script). See explainer and OT write-up.
Developer demand:
- first-hand reports in whatwg/html#10997 (e.g. shared WebSocket across navigations, wasm re-init costs); 35 origins in the Chrome OT.
Compatibility impact: not polyfillable — without the option the worker is killed and the data is lost.
Platform impact:
- lifetime capped at the service-worker no-client lifetime, so no new background-execution capability
- replaces a persistent SW registration with a short-lived worker. See the explainer's security/privacy self-review.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
github-actions commentedon Sep 8, 2026
This comment was automatically generated based on the information you provided. Please don't edit it.
Below is additional information about the web feature (from the web-features project) which is referenced in your proposal.
If this doesn't accurately correspond to your proposal, please update your initial comment to include
web-features: <feature-id>.To find feature IDs, use the web-features explorer.
Feature Shared worker extended lifetime
extendedLifetimeoption of theSharedWorker()constructor gives shared workers extra time to perform operations after all pages using it have been navigated away from or closed.