title: What should I do with the redundant state of a ServiceWorker?
body: <p>I gotta a companion script for a serviceworker and I'm trialling right now. </p>
  
  <p>The script works like so: </p>
  
  <pre><code>((n, d) =&gt; {
  
    if (!(n.serviceWorker &amp;&amp; (typeof Cache !== 'undefined' &amp;&amp; Cache.prototype.addAll))) return; 
  
    n.serviceWorker.register('/serviceworker.js', { scope: './book/' })
      .then(function(reg) {
  
          if (!n.serviceWorker.controller) return;
  
          reg.onupdatefound = () =&gt; {
  
            let installingWorker = reg.installing;
  
            installingWorker.onstatechange = () =&gt; {
              switch (installingWorker.state) {
                case 'installed':
                  if (navigator.serviceWorker.controller) {
                    updateReady(reg.waiting);
  
                  } else {
                    // This is the initial serviceworker…
                    console.log('May be skipwaiting here?');
                  }
                  break;
  
                case 'waiting':
                  updateReady(reg.waiting);
                  break;
  
                case 'redundant':
                  // Something went wrong?
                  console.log('[Companion] new SW could not install…')
                  break;
              }
            };
          };
      }).catch((err) =&gt; {
        //console.log('[Companion] Something went wrong…', err);
      });
  
      function updateReady(worker) {
          d.getElementById('swNotifier').classList.remove('hidden');
  
          λ('refreshServiceWorkerButton').on('click', function(event) {
            event.preventDefault();
            worker.postMessage({ 'refreshServiceWorker': true } );
          });
  
          λ('cancelRefresh').on('click', function(event) {
            event.preventDefault();
            d.getElementById('swNotifier').classList.add('hidden');
          });
  
      }
  
      function λ(selector) {
  
        let self = {};
  
        self.selector = selector;
  
        self.element = d.getElementById(self.selector);
  
        self.on = function(type, callback) {
          self.element['on' + type] = callback;
        };
  
        return self;
      }
  
      let refreshing;
  
      n.serviceWorker.addEventListener('controllerchange', function() {
        if (refreshing) return;
        window.location.reload();
        refreshing = true;
      });    
  
  
  })(navigator, document);
  </code></pre>
  
  <p>I'm a bit overwhelmed right now by the enormity of the service workers api and unable to "see" what one would do with <code>reg.installing</code> returning a <code>redundant</code> state? </p>
  
  <p>Apologies if this seems like a dumb question but I'm new to serviceworkers.</p>