Skip to content

Commit 2ce1826

Browse files
erkamyamanatscott
authored andcommitted
docs(service-worker): note that registerWhenStable requires a timeout
`registerWhenStable` without a `:<timeout>` does not wait for the application to stabilize. It registers the ServiceWorker immediately, so the JSDoc promising the opposite sends readers to the one form of the strategy that does not do what they want. Suggested in angular#71018.
1 parent 0ebea40 commit 2ce1826

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎adev/src/content/ecosystem/service-workers/getting-started.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ export const appConfig: ApplicationConfig = {
256256
Available registration strategies:
257257

258258
- **`'registerWhenStable:timeout'`** (default: `'registerWhenStable:30000'`) - Register as soon as the application stabilizes (no pending micro-/macro-tasks) but no later than the specified timeout in milliseconds
259+
The timeout is required. Without it, `'registerWhenStable'` registers the service worker immediately.
259260
- **`'registerImmediately'`** - Register the service worker immediately
260261
- **`'registerWithDelay:timeout'`** - Register with a delay of the specified timeout in milliseconds
261262

‎packages/service-worker/src/provider.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ export abstract class SwRegistrationOptions {
198198
* micro-/macro-tasks) but no later than `<timeout>` milliseconds. If the app hasn't
199199
* stabilized after `<timeout>` milliseconds (for example, due to a recurrent asynchronous
200200
* task), the ServiceWorker will be registered anyway.
201-
* If `<timeout>` is omitted, the ServiceWorker will only be registered once the app
202-
* stabilizes.
201+
* `<timeout>` is required. Without it, the ServiceWorker is registered immediately
202+
* instead of waiting for the application to stabilize.
203203
* - `registerImmediately`: Register immediately.
204204
* - `registerWithDelay:<timeout>`: Register with a delay of `<timeout>` milliseconds. For
205205
* example, use `registerWithDelay:5000` to register the ServiceWorker after 5 seconds. If

0 commit comments

Comments
 (0)