I have a service worker which calls an API I am developing. This API returns a promise but the promise can resolve at some later point in time. It relies on an internal browser function.
This API seems to work fine while my document is active and in a tab, but if I close the tab I never see the promise getting resolved. Even though I am calling RunOrPostTaskOnThread with the appropriate callback. Somehow this promise disappears.
From reading what I can on service worker lifespans and from looking at chrome://serviceworker-internals I am expecting that the service worker should still be able to see this promise resolving.
Here is what internals is telling me:
Registration ID: 41
Navigation preload enabled: false
Navigation preload header length: 4
Installation Status: ACTIVATED
Running Status: STOPPED
Fetch handler existence: EXISTS
Version ID: 63
Renderer process ID: 0
Renderer thread ID: -1
DevTools agent route ID: -2
I am new to service workers so I am wondering what I have misunderstood. Should I be using an event here rather than a promise?