Forum Discussion

elidupuis's avatar
elidupuis
Copper Contributor
Oct 23, 2020

Potential bug retrieving service worker notifications on macOS

I've been digging into an odd issue for a while and I think I've discovered a potential bug in Edge on macOS. I've tested this in version 86, 87 (beta), and 88 (dev). It does not appear to be present on Windows.

 

In short, the service worker registration method getNotifications() is supposed to return a promise but, under certain circumstances, it never seems to fulfill (neither resolves nor rejects) in MS Edge on macOS if notification permissions have been granted by the user.

 

The bug only exists if Notification.permission === 'granted', meaning that the user has granted permissions for notifications at the browser level.

 

You can easily test this on any PWA. For example, app.starbucks.com is a well-known PWA and this bug can be replicated in DevTools console on their site.

 

First, you'll need to ensure notification permissions are granted. Then, simply run the test snippet (below) in the browser console. The bug is not present with a permission state or either default or denied. This snippet simply calls the method in question and logs out some details along the way.

 

 

 

console.log(navigator.userAgent)
navigator.serviceWorker.ready
.then(reg => {
  console.log('> SW READY')
  console.log('Permission state:', Notification.permission);
  return reg.getNotifications();
}).then(notifications => {
  console.log('Notifications:', notifications);
})
.catch(e => console.log('> ERROR', e))
.finally(() => console.log('> COMPLETE'))

 

 

 

The expected output is that you see a list of notifications (likely an empty array) or you see an error logged in the console. Finally, after the promise chain has completed, you should see "> COMPLETE" logged in the console. Here's an example from Chrome:

 

 

However, under these same circumstances in Edge (on macOS), the promise stalls. It never resolves nor rejects; meaning that this snippet never reaches the .then.catch, nor .finally blocks. 

 

In my application, I'm trying to run this as part of the user sign-out flow and this bug simply freezes the application because the promise never fulfills. This is a big problem because it means the user can't properly sign out of the application.

 

That pretty much sums it up. I hope someone can provide some insight or guidance on this issue. Thanks in advance!

 

I've created a gist outlining these details and briefly summarized on Twitter as well.




  • Hi elidupuis,

     

    Thank you very much for reporting this issue. Apologies we've gotten back to this late!

     

    As you provided the details, our feature team reproduced the issue and is currently working on a fix. I'll keep you posted in this thread when we start to roll out the fix.

     

    Thank you,
    Jungkee Song
    PM, Microsoft Edge

Resources