web-platform-tests / web-platform-tests/interop
Extended lifetime shared workers (`SharedWorkerOptions.extendedLifetime`)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 524
- Forks
- 35
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 10
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:
- https://github.com/whatwg/html/issues/10997
- https://github.com/whatwg/html/pull/11600
- https://github.com/whatwg/html/issues/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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the listed SharedWorker-extendedLifetime WPTs and shared-worker-options-mismatch.html, then review the WHATWG HTML specification entry and the linked Firefox and WebKit bugs. Done means browser support matches the specification and the extendedLifetime behavior and option-mismatch tests pass in the currently failing engines.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100