This is happening on Chrome only (application doesn't support any other browsers for now) and on recent versions.
I can't reproduce this issue, but it regularly shows up in our monitoring dashboard for random users.
Error message: "AbortError: Registration failed - push service error"
The following code block runs on page load:
const currentNotificationsPermission = await navigator.permissions.query({ name: 'notifications' });
currentNotificationsPermission.onchange = function onchange() {
// Update the internal state, this can happen after user interaction (clicking a "Allow notifications" button)
};
This runs on pageload (when the internal state is granted), or whenever the internal state changes to granted after a user gesture:
navigator.serviceWorker.register('/serviceworker.js', { scope: '/myScope' });
navigator.serviceWorker.ready.then((registration) => {
const subscribeOptions = {
userVisibleOnly: true,
applicationServerKey: 'myKey',
};
return registration.pushManager.subscribe(subscribeOptions);
}).then((pushSubscription) => {
// Send pushSubscription to server, doesn't run in case of AbortError
}).catch((err) => {
console.log(err); // AbortError, randomly
});