DEV Community

Discussion on: What does event.waitUntil do in service worker and why is it needed?

Collapse
 
sargalias profile image
Spyros Argalias

According to the MDN docs on ExtendableEvent.waitUntil() it prevents the service worker from terminating until the work inside the function is done. This is because the work inside the function is asynchronous, it could potentially take many seconds to complete.

Essentially it just waits for the promise to be fulfilled.