Re: [w3c/ServiceWorker] postMessage keeps service workers alive indefinitely (#980)

We decided that background sync can only be called when there's a document open on the origin. This prevents one-off background sync being turned into a periodic sync by recalling sync inside a sync event.

We'll want something similar for background fetch, but it'd be nice to be able to start a download in response to a push message.

I wonder if we can fix all these things with the same mechanism.

When we create an extendable event, we can assign an expiry time to it.

* A fetch event gets an expiry time of x minutes
* A `postMessage` sent by a client with an associated document (so a document or a worker linked to a document) gets an expiry time of x minutes
* A `postMessage` sent by a service worker A to service worker B gets an expiry time equal to the longest expiry time currently holding service worker A open

This means two service workers post messaging each other can only stay alive for a total of 5 minutes.

If we're tagging extendable events like this, we can also say things like "background sync can only be used if the SW is being held open by a push/fetch event".

Too crazy?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/980#issuecomment-248920422

Received on Thursday, 22 September 2016 14:31:04 UTC