Skip to content

Commit

Permalink
Merge pull request #1825 from Soxasora/fix_sw_uncaught_promise
Browse files Browse the repository at this point in the history
fix: uncaught promise on getOS causes onMessage event to end early
  • Loading branch information
huumn authored Jan 18, 2025
2 parents a895a91 + 1cbf5ab commit 566a5f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sw/eventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export function onMessage (sw) {
messageChannelPort = event.ports[0]
}
log('[sw:message] received message', 'info', { action: event.data.action })
const currentOS = await getOS()
const currentOS = event.waitUntil(getOS())
log('[sw:message] stored os: ' + currentOS, 'info', { action: event.data.action })
if (event.data.action === STORE_SUBSCRIPTION) {
log('[sw:message] storing subscription in IndexedDB', 'info', { endpoint: event.data.subscription.endpoint })
Expand All @@ -253,8 +253,8 @@ export function onMessage (sw) {
promises.push(sw.registration.getNotifications().then((notifications) => {
notifications.forEach(notification => notification.close())
}))
activeCount = 0
promises.push(clearAppBadge(sw))
activeCount = 0
event.waitUntil(Promise.all(promises))
}
}
Expand Down

0 comments on commit 566a5f9

Please sign in to comment.