User Profile
elidupuis
Copper Contributor
Joined 5 years ago
User Widgets
Recent Discussions
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, theservice worker registration methodgetNotifications()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 ifNotification.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.comis 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 eitherdefaultordenied. 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.finallyblocks. 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 detailsand briefly summarized on Twitter as well.1.6KViews0likes1Comment
Groups
Recent Blog Articles
No content to show