Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reliably update service worker #2638

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/messaging/src/controllers/window-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ export class WindowController implements FirebaseMessaging, FirebaseService {
scope: DEFAULT_SW_SCOPE
}
);

// The timing when browser updates sw when sw has an update is unreliable by my experiment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by my experiment.

This bit won't really matter to a reader in the future 😄

// It leads to version conflict when the SDK upgrades to a newer version in the main page, but
// sw is stuck with the old version. For example, https://github.com/firebase/firebase-js-sdk/issues/2590
// The following line reliably updates sw if there was an update.
this.swRegistration.update().catch(() => { /* it is non blocking and we don't care if it failed */ });
} catch (e) {
throw ERROR_FACTORY.create(ErrorCode.FAILED_DEFAULT_REGISTRATION, {
browserErrorMessage: e.message
Expand Down