title: How do I detect Workbox.register precache request failure?
body: <p>I register my serviceworker through Workbox with</p>
  
  <pre><code>        const wb = new Workbox("/sw.js");
  
          wb.register();
  </code></pre>
  
  <p>This works great, and installs no problems. ( I am using workbox-precaching, and SWInjectManifest built through webpack )</p>
  
  <p>My problem comes when I deliberately force one of the requests in my precaching manifest to fail, which I do by deleting one built file.</p>
  
  <p>Workbox dev logging tells me </p>
  
  <pre><code>Service worker installation failed. It will be retried automatically during the next navigation.
  
  Uncaught (in promise) bad-precaching-response: The precaching request for 'http://localhost:8080/GalanoGrotesqueAlt-Regular.woff' failed with an HTTP status of 404.
  </code></pre>
  
  <p>Ideally I'd like to let the user retry. I build apps that are used in low quality network environments, so detecting these errors can be quite important.</p>
  
  <p>I have tried:</p>
  
  <ol>
  <li>wrapping <code>wb.register()</code> in a try catch ( it does not raise an exception )</li>
  <li>chaining a <code>.catch()</code> off <code>wb.register()</code> ( it does not return a promise )</li>
  <li>listening to non-existent 'error' events on Workbox ( they don't exist )</li>
  <li>wrapping the call to <code>precacheAndRoute</code> in the service worker ( it does not raise an exception )</li>
  <li>listening to 'error' events on the ServiceWorkerController ( which is <a href="https://github.com/w3c/ServiceWorker/issues/912" rel="nofollow noreferrer">unsupported</a> )</li>
  <li>setting self.onerror, and listening to self <code>error</code> events in the serviceworker code ( they do not fire )</li>
  </ol>
  
  <p><a href="https://plnkr.co/edit/jymNXaeLvsZU1OJx?preview" rel="nofollow noreferrer">https://plnkr.co/edit/jymNXaeLvsZU1OJx?preview</a></p>
  
  <p>My two options now are:</p>
  
  <ol>
  <li>try to use webpack alias to override the workbox logger code</li>
  <li>just offer a retry button after a guestimated time</li>
  </ol>
  
  <p>I love the plugins workbox gives me, but the abstraction is beginning to hurt.</p>