TECHNOLOGY

Service-worker installation: detached promises do not gate offline readiness

In this article
THE QUICK TAKE

Register the complete required preparation promise with the install event; successful registration or a detached asynchronous task does not prove the offline package is ready.

Registration is announced as offline readiness

A browser assistant registers a service worker and displays an offline-ready badge. During installation, a helper begins preparing model resources but returns before its asynchronous work finishes. The event handler completes without tracking that work. The visible badge now describes registration rather than the application’s required package. Start by naming the exact prerequisite: which resources must exist before offline operation is promised, and which promise actually represents their completed preparation rather than merely launching background activity.

Extend the relevant event with the complete chain

The Service Workers specification defines waitUntil as extending an event’s lifetime with a promise and constrains when lifetime promises can be added. Attach the complete required asynchronous chain while the event is eligible. Returning a promise from an unrelated helper does not automatically register it with the event. Also inspect nested helpers: a chain that resolves before its final cache or storage operation completes still describes the wrong prerequisite, even when the outer handler visibly calls waitUntil.

Installation failure must remain visible

The Chrome lifecycle guide explains that rejected installation promises cause installation to fail. Preserve that outcome when required preparation fails. Swallowing every rejection and resolving a success-shaped value makes the lifecycle unable to represent missing essentials. Define optional resources separately so their absence does not accidentally block a deliberately narrower offline mode. The distinction belongs in the application contract, not in a blanket error handler that relabels all missing data as successful preparation.

Installation and page control are different observations

The lifecycle guide distinguishes successful installation, activation and when a worker controls a page. An existing page may still follow a different controller relationship from the newly installed worker. Inspect the actual loading path used by the assistant rather than inferring it from a registration object. A prepared resource that the current page never requests through the intended path cannot prove the live session is offline-capable. Likewise, waitUntil is not an unlimited background-compute reservation or a durable replacement for stored progress.

Propose a preparation-failure fixture

Use harmless small resources and delay the last required preparation operation. Compare a detached helper with the correctly connected promise chain, then reject a required resource and inspect installation outcome and the displayed readiness state. Finally verify the actual controlled-page path without network access. Acceptance requires no premature offline promise and clear optional-resource behavior. No worker was installed or cache modified here; this fixture specifies lifecycle evidence and does not claim a completed browser compatibility test.

Combine lifecycle evidence with artifact identity

Pinned offline snapshots establish intended model contents. Packaged application assets establish another inclusion boundary. Service-worker installation adds an event-lifetime and page-control boundary; it does not replace either identity check. Keep the required promise, installation outcome, current controller and actual offline load result visible. This yields a precise readiness claim without treating a registered worker or an asynchronously started download as a complete local inference environment.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles