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

fix(setupWorker): perform worker update in the background #2311

Merged
merged 1 commit into from
Oct 10, 2024
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
22 changes: 12 additions & 10 deletions src/browser/setupWorker/start/utils/getWorkerInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ export const getWorkerInstance = async (
const [existingRegistration] = mockRegistrations

if (existingRegistration) {
// When the Service Worker is registered, update it and return the reference.
return existingRegistration.update().then(() => {
return [
getWorkerByRegistration(
existingRegistration,
absoluteWorkerUrl,
findWorker,
),
// Schedule the worker update in the background.
// Update ensures the existing worker is up-to-date.
existingRegistration.update()

// Return the worker reference immediately.
return [
getWorkerByRegistration(
existingRegistration,
]
})
absoluteWorkerUrl,
findWorker,
),
existingRegistration,
]
}

// When the Service Worker wasn't found, register it anew and return the reference.
Expand Down
Loading