Skip to content

Commit

Permalink
fixup! fix race condition getting wrong sw registration
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Nov 16, 2023
1 parent 7930f20 commit 25628d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/shared/managers/ServiceWorkerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class ServiceWorkerManager {
});
}

// Returns true if a the OneSignal service worker can't be installed
// Returns false if the OneSignal service worker can't be installed
// or is already installed and doesn't need updating.
private async shouldInstallWorker(): Promise<boolean> {
// 1. Does the browser support ServiceWorkers?
Expand Down Expand Up @@ -541,7 +541,7 @@ export class ServiceWorkerManager {
`[Service Worker Installation] Service worker installed. Waiting for activation`,
);

await ServiceWorkerUtilHelper.waitForServiceWorkerToActive(registration);
await ServiceWorkerUtilHelper.waitUntilActive(registration);

Log.debug(`[Service Worker Installation] Service worker active`);

Expand Down
2 changes: 1 addition & 1 deletion src/sw/helpers/ServiceWorkerUtilHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class ServiceWorkerUtilHelper {
// Allows waiting for the service worker registration to become active.
// Some APIs, like registration.pushManager.subscribe, required it be active
// otherwise it throws.
static waitForServiceWorkerToActive(
static waitUntilActive(
registration: ServiceWorkerRegistration,
): Promise<void> {
return new Promise((resolver) => {
Expand Down

0 comments on commit 25628d2

Please sign in to comment.