BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉

Home Page:https://partytown.builder.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the expected behaviour when a user closes the tab before the service worker completes a task?

edwardmyung opened this issue · comments

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:

  1. if I trigger the logger on the main thread, then close the tab shortly after, the log doesn't appear
  2. 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:

  1. 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?
  2. Should the delay to process the event in the service-worker be so long (>10 seconds)?

Thanks