title: How does global error handling work in service workers?
body: <p>I found <a href="https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onerror" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/onerror</a> which says:</p>
  
  <blockquote>
    <p>The onerror property of the ServiceWorkerContainer interface is an
    event handler fired whenever an error event occurs in the associated
    service workers.</p>
  </blockquote>
  
  <p>However I'm not able to get this working in Chrome (v51). In the scope of the main application, I ran the following code from the console:</p>
  
  <pre><code>navigator.serviceWorker.onerror = function(e) { console.log('some identifiable string' + e); };
  </code></pre>
  
  <p>Then within the scope of the active service worker I triggered an arbitrary error:</p>
  
  <pre><code>f(); // f is undefined
  </code></pre>
  
  <p>The result was the usual "Uncaught ReferenceError: f is not defined(…)" error message but it was not logged through my global onerror handler.</p>
  
  <p>The MDN page says that this API has been supported in Chrome since v40, but <code>navigator.serviceWorker.onerror</code> is initially undefined which leads me to believe that it's unimplemented. Is anyone familiar with this?</p>