refactor: use Promise.all for service worker unregistration

Co-authored-by: hyoban <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-23 03:31:32 +00:00
parent 57df92aba7
commit b5a7e7aede

View File

@ -7,15 +7,17 @@ import { IS_DEV } from '@/config'
export function PWAProvider({ children }: { children: React.ReactNode }) {
useEffect(() => {
if (IS_DEV && 'serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then((registrations) => {
registrations.forEach((registration) => {
registration.unregister()
navigator.serviceWorker.getRegistrations()
.then((registrations) => {
return Promise.all(
registrations.map(registration => registration.unregister()),
)
})
.catch((error) => {
// Silently fail if service worker unregistration fails
// This is a development-only optimization and shouldn't block the app
console.warn('Failed to unregister service workers:', error)
})
}).catch((error) => {
// Silently fail if service worker unregistration fails
// This is a development-only optimization and shouldn't block the app
console.warn('Failed to unregister service workers:', error)
})
}
}, [])