What is the expected behaviour when a user closes the tab before the service worker completes a task?
edwardmyung opened this issue · comments
Edward Myung commented
Background
I have setup Partytown to handle logging with Datadog, and calls to the logger e.g. DD_LOGS.logger.info('some log')
currently do process successfully off the main thread.
However, I'm finding that:
- if I trigger the logger on the main thread, then close the tab shortly after, the log doesn't appear
- if I trigger the logger on the main thread, the network call (from the service-worker) to datadog seems to take a long time, often >10 seconds
Questions
When partytown is setup correctly:
- Should the service worker stay alive to complete the task, or is it expected that this function call won't succeed if the tab is closed before the service-worker completes the network call for the log?
- Should the delay to process the event in the service-worker be so long (>10 seconds)?
Thanks