title: Web push exception: AbortError: Registration failed - storage error
body: <p>I have the following code for a website with a web push service:</p>
  
  <p>service-worker.js
  </p>
  
  <pre><code>self.addEventListener('push', function(event) {
    console.log('[Service Worker] Push Received.');
    console.log(`[Service Worker] Push had this data: "${event.data.text()}"`);
  
    const title = 'Push Codelab';
    const options = {
      body: 'Nice!.',
      icon: 'images/icon.png',
      badge: 'images/badge.png'
    };
  
    event.waitUntil(self.registration.showNotification(title, options));
  });
  
  self.addEventListener('notificationclick', function(event) {
    console.log('[Service Worker] Notification click Received.');
  
    event.notification.close();
  
    event.waitUntil(
      clients.openWindow('https://www.google.com/')
    );
  });
  </code></pre>
  
  <p>main.js
  </p>
  
  <pre><code>const applicationServerPublicKey = 'BKCPC_aWgr4rYVSTZ90xScxwRnkd5f4L0DhR2f_yQ_0XMKQ423E2upAAweFsXHfvG2VaOjmlOuoG-MAdocrZD20';
  
  if ('serviceWorker' in navigator) {
      navigator.serviceWorker.getRegistrations().then(function (registrations) {
          for (let registration of registrations) {
              registration.unregister()
          }
      })
      // register service worker
      navigator.serviceWorker.register('./service-worker.js')
      .then(function(swReg) {
      console.log('Service Worker is registered', swReg);
  
      swRegistration = swReg;
    })
    .catch(function(error) {
      console.error('Service Worker Error', error);
    });
  }
  
  function subscribeUser() {
      const applicationServerKey = urlB64ToUint8Array(applicationServerPublicKey);
      swRegistration.pushManager.subscribe({
          userVisibleOnly: true,
          applicationServerKey: applicationServerKey
      })
          .then(function(subscription) {
          console.log('User is subscribed.');
  
          updateSubscriptionOnServer(subscription);
  
          isSubscribed = true;
  
      })
          .catch(function(err) {
          document.getElementById("test").innerHTML = err;
          console.log('Failed to subscribe the user: ', err);
      });
  }
  
  function updateSubscriptionOnServer(subscription) {
    // TODO: Send subscription to application server
  
    if (subscription) {
        var isError = true;
        do{
            try
                {
                    document.getElementById("test").innerHTML = JSON.stringify(subscription);
                    isError = false;
                }
            catch(e){
  
        }
        }while(isError);
    } else {
      //Error
    }
  }
  </code></pre>
  
  <p>index.html
  </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;Simple Tribal Wars Bot&lt;/title&gt;
      &lt;link rel="icon" href="images/icon.ico"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;meta name="theme-color" content="#C6A715"/&gt;
      &lt;link rel="manifest" type="application/manifest+json" href="manifest.json"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/master.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/style.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/media-query.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" /&gt;
      &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.1.0/css/flag-icon.css" /&gt;
      &lt;link href="https://fonts.googleapis.com/css?family=Righteous" rel="stylesheet"&gt;
  &lt;/head&gt;
  
  &lt;body id="body"&gt;
      &lt;script src="https://js.pusher.com/4.1/pusher.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"&gt;&lt;/script&gt;
      &lt;script src="js/cHdaqwhdQ.js"&gt;&lt;/script&gt;
      &lt;script src="js/main.js?v=0.0.0.47"&gt;&lt;/script&gt;
      &lt;header&gt;
      &lt;/header&gt;
      &lt;nav&gt;
      &lt;/nav&gt;
      &lt;main&gt;
          &lt;section id="main-section" class="bd-index-fullscreen hero is-loading is-fullheight is-dark hcenter"&gt;
              &lt;div class="hero-head"&gt;
              &lt;/div&gt;
              &lt;div class="hero-body"&gt;
                  &lt;p id="test"&gt;&lt;p&gt;
                  &lt;noscript class="hcenter"&gt;
                      &lt;div&gt;
                          &lt;h1 class="is-danger"&gt;JavaScript must be activated to use this page!&lt;/h1&gt;
                      &lt;/div&gt;
                  &lt;/noscript&gt;
  
              &lt;/div&gt;
          &lt;/section&gt;
      &lt;/main&gt;
      &lt;footer&gt;
      &lt;/footer&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>The error (AbortError: Registration failed - storage error) does not appear every time. Sometimes it's working, sometimes it's not.</p>
  
  <p>Do you have an idea, with what it could have to do?</p>