title: What cleanup is needed when a chrome extension service worker becomes suspended?
body: <p>Chrome Extension documentation describes the <code>onSuspend</code> listener as a way to do &quot;some cleanup&quot; when an extension's service worker is shutting down.</p>
  <p>Should I remove all active listeners (i.e. webRequest listeners) in this callback, or is that not needed and they'll be removed automatically upon suspension?</p>
  <p>Is there any &quot;cleanup&quot; that is important to do, aside from my own app logic's state management?</p>
  <p><strong>onSuspend</strong></p>
  <pre><code>chrome.runtime.onSuspend.addListener(
    callback: function,
  )
  </code></pre>
  <blockquote>
  <p>Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded.</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/gU19I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gU19I.png" alt="documentation" /></a></p>