Deprecate the service worker helpers the application can write itself - #455
Open
Spomky wants to merge 1 commit into
Open
Deprecate the service worker helpers the application can write itself#455Spomky wants to merge 1 commit into
Spomky wants to merge 1 commit into
Conversation
This was referenced Aug 14, 2026
Spomky
force-pushed
the
feature/deprecate-controllers-and-helpers
branch
4 times, most recently
from
August 16, 2026 20:50
53e9b04 to
2498b0f
Compare
Most of the helpers emitted by WorkboxHelpers wrap service worker events the bundle itself never populates: push, notificationclick, message, periodicsync and the three backgroundfetch events have no producer on the PHP side. Since service worker listeners are additive and the application source is appended last by the compiler, a plain self.addEventListener() in that source does the same job without the indirection. A helper now belongs in WorkboxHelpers only when it arbitrates an order between several rules generated by the bundle (registerInstallTask, with ClearCache at 0, SkipWaiting at 5, OfflineFallback at 10 and the cache strategies at 100) or carries a state shared between them (registerCacheName, read back by ClearCache). The rest moves to WorkboxDeprecatedHelpers, emitted as long as pwa.serviceworker.workbox.keep_deprecated_helpers is true, so upgrading changes nothing until the application opts out. The SKIP_WAITING handler stays: it is the service worker half of the contract with the workbox-window registration injected by PwaRuntime. It no longer goes through registerMessageTask. Deprecation is reported twice, on purpose. trigger_deprecation() fires from the extension when the option is left to true, which reaches the applications that configure nothing; and each deprecated function warns from its own body, so an application that stopped calling them gets a silent service worker. The option itself is not marked deprecated: setDeprecated() only fires when a node is written out, which would have warned exactly those who already migrated. background_fetch goes with them. It decides for the application that a click opens a given URL, that downloads are chunked into a fixed IndexedDB schema and that the notification title is rewritten. Setting keep_deprecated_helpers to false while it is enabled now fails at container build time rather than with a bare ReferenceError in the browser. Only openBackgroundFetchDatabase() used self.idb, so idb is no longer imported nor copied to the public folder once the deprecated helpers are switched off.
Spomky
force-pushed
the
feature/deprecate-controllers-and-helpers
branch
from
August 17, 2026 06:47
2498b0f to
79c8ff9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of the scope reduction announced in #372: the bundle keeps the manifest, the service worker, the favicons and the icons, and stops growing its client-side surface.
Nothing is removed here. Everything stays emitted by default and only becomes opt-out, so upgrading to 1.6.0 changes no behaviour.
The line
Most helpers emitted by
WorkboxHelperswrap service worker events the bundle itself never populates:push,notificationclick,message,periodicsyncand the threebackgroundfetchevents have no producer on the PHP side. Service worker listeners are additive, and the application source configured throughserviceworker.srcis appended last by the compiler, so a plainself.addEventListener()there does the same job without the indirection.A helper stays in
WorkboxHelpersonly when it:registerInstallTask(ClearCacheat 0,SkipWaitingat 5,OfflineFallbackat 10, cache strategies at 100) andprecacheResources;registerCacheName/openCache, whoseusedCacheNamesset is read back byClearCache;WorkboxPlugin\*:statusGuard,createBackgroundSyncPlugin,createBackgroundSyncPluginWithBroadcast.Everything else moves to the new
WorkboxDeprecatedHelpers:registerCacheFirst(which had no caller at all),registerMessageTask,registerPushTask,registerNotificationAction,registerPeriodicSyncTask,registerBackgroundFetchTaskand the background fetch storage. The emitted JavaScript is byte-identical to what it was, plus the deprecation warnings.The
SKIP_WAITINGhandler stays: it is the service worker half of the contract with theworkbox-windowregistration injected byPwaRuntime, where the page callswb.messageSkipWaiting(). It is now a plain listener instead of aregisterMessageTaskcall.Isolating them in one class makes 2.0.0 a
git rm.Reporting the deprecation
Twice, on purpose, because the two signals reach different people.
trigger_deprecation()fires from the extension whenkeep_deprecated_helpersis left totrue, which reaches the applications that configure nothing. And each deprecated function warns from its own body throughreportDeprecatedHelper(), once per name, so an application that already stopped calling them gets a silent service worker.The option itself is deliberately not marked with
setDeprecated(): a deprecated node only fires when it is explicitly written out, which would have warned exactly those who already migrated and stayed silent for everyone else.Background fetch
background_fetchis deprecated too. It decides for the application that a click opens a given URL, that downloads are chunked into a fixed IndexedDB schema and that the notification title is rewritten with{title} ✅.BackgroundFetchCachecallsregisterBackgroundFetchTask(), so settingkeep_deprecated_helperstofalsewhile background fetch is enabled now fails at container build time with an explicit message, rather than with a bareReferenceErrorin the browser.The duplicated
db_namenode, declared twice in the definition, is removed.idb
openBackgroundFetchDatabase()was the only consumer ofself.idb. Once the deprecated helpers are switched off, the library is no longer imported byWorkboxImport(CDN and local paths) nor copied to the public folder byServiceWorkerCompiler.self.idbin its ownserviceworker.src: it must switch toindexedDB.open()or import the library itself. To be covered in the upgrade guide.Migration
Before flipping it, replace the calls in your own service worker source:
Checks
WorkboxHelpersTest,WorkboxDeprecatedHelpersTestandWorkboxImportTestnode --checkin both configurationsStill to come
The
console.warnin the Stimulus controllers, thenpm deprecateon@spomky-labs/pwa-bundle, the documentation and the upgrade guide.