0

I have a service worker with an onMessage listener.

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
   longRunningTask()
     .then(handleResult)
   sendResponse({success: true})

   return true
})

When I send the message to trigger this, the longRunningTask will begin, but it takes quite a while to execute, so the service worker will suspend itself and cancel the task before it finishes.

How can I prevent the service worker from ending prematurely?

Shaun Wild
  • 1,237
  • 3
  • 16
  • 33
  • 1
    I think our questions may differ, my tasks are running for 1-2 minutes and they're being shut down within seconds, whereas this question is asking how to get around the 5 minute hard cap. – Shaun Wild Jun 20 '21 at 15:36

0 Answers0