-
Notifications
You must be signed in to change notification settings - Fork 318
waitUntil()
for FetchEvent?
#584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is this a more realistic use case for http://jakearchibald.com/2014/offline-cookbook/#stale-while-revalidate A |
Yeah, you're right, that is more realistic. Analytics pings are another area that this might be useful in. |
How long to hold the worker alive with outstanding network requests came up in our internal discussion again today. Would be nice to move forward on this or define some other life cycle guidelines here. I believe @annevk would like a fully defined life cycle model. While that would be nice, I personally think we can make progress by defining something like |
I'm not sure those are in opposition. |
I agree. I was trying to say I don't want to wait until we have a fully defined life cycle model. I'd like to clarify this particular use case sooner. |
Ah, right. Good call. |
Interesting question: do you need to let it run at least as long as the TCP timeout, which 60 seconds on modern Linux? I'd suggest that as a reasonable starting point. Thoughts? @jakearchibald? @KenjiBaheux? @coonsta? @kinu? |
@wanderview In your comment above, did you mean @jakearchibald What patterns can you expect for devs with the |
I agree that there could probably be a situation where one wants to explicitly extend the lifetime of an event (and hence ServiceWorker) up to a certain point after it returns a response, assuming that in general we want ServiceWorker to return a response as early as possible for performance reasons. Reg: TCP timeout-- it's not clear if we need to tie the lifetime of SW to the completion of async network/cache operation. It looks we could say that async network/cache operation that is triggered by a ServiceWorker will NOT be cancelled even after the ServiceWorker is killed (by UA), like we don't for Beacon API on page unload. (Currently the behavior of async operations upon SW termination doesn't seem to be really spec'ed?) |
Yes. I meant if we had a general waitUntil(), it could be used to keep the worker alive until cache.put() completes, even though respondWith() has already been called. As a side note, I am changing the gecko Cache implementation to keep the worker alive as long as there are Cache operations in flight. This is partly for ipc implementation details, but also partly due to the lack of waitUntil(). |
I believe adding |
Yeah, so it sounds like it's an optimization point in the implementation rather than a constraint in the spec.
Yes, I think I need to add more text to make it clear. IMO, ongoing fetch can just be dropped as there's no context to process or relay the response through. And for cache operations, those responses already committed to the request to response map might better be retained unless it fails. Thoughts? |
ff93a46 made the |
Opened #679 for the default lifetime limit issue. Closing. |
Gecko impl bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1214772 |
AKA: should
FetchEvent
be anExtendableEvent
?It's possible today to write code that fetches from the network, adds to a cache, and then matches from the cache in order to feed a document. This seems a bit weird...why invoke the Cache matching mechanism for a
Response
you've already got a handle to and can simply.clone()
?The answer, today, is the lifetime concern: you want the
respondWith
promise to extend beyond the point where the Cache is savvy to the cache entry. This is a bit weird. Mightn't it be better to giveFetchEvent
awaitUntil()
?The text was updated successfully, but these errors were encountered: