Skip to content
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

waitUntil called on event that is already finished in NetworkFirst strategy #1386

Closed
jeffposnick opened this issue Mar 23, 2018 · 3 comments · Fixed by #1392
Closed

waitUntil called on event that is already finished in NetworkFirst strategy #1386

jeffposnick opened this issue Mar 23, 2018 · 3 comments · Fixed by #1392
Assignees
Labels
Bug An issue with our existing, production codebase. workbox-strategies

Comments

@jeffposnick
Copy link
Contributor

Library Affected:
workbox-strategies

Browser & Platform:
webview with User-Agent:Mozilla/5.0 (Linux; Android 6.0.1; SM-A510F Build/MMB29K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Mobile Safari/537.36

Issue or Feature Request Description:
Reported by @beatrizdemiguelperez on Slack:

i'm getting this error while trying to fetch a file with networkFirst strategy

Uncaught (in promise) DOMException: Failed to execute 'waitUntil' on 'ExtendableEvent': The event handler is already finished.
   at http://localhost:4200/workbox-v3.0.0/workbox-strategies.dev.js:510:15
   at Generator.next (<anonymous>)
   at step (http://localhost:4200/workbox-v3.0.0/workbox-core.dev.js:14:32)
   at http://localhost:4200/workbox-v3.0.0/workbox-core.dev.js:25:15
@jeffposnick jeffposnick added Bug An issue with our existing, production codebase. workbox-strategies labels Mar 23, 2018
@jeffposnick
Copy link
Contributor Author

The underlying code is

// Keep the service worker alive while we put the request in the cache
const responseClone = response.clone();
event.waitUntil(
cacheWrapper.put(
this._cacheName,
event.request,
responseClone,
this._plugins
)
);

There's some setTimeout() logic in the handler that might be leading to a race condition.

@beatrizdemiguelperez
Copy link

beatrizdemiguelperez commented Mar 26, 2018

Also reproduced on:
Browser & Platform:
Chrome Mobile with User-Agent:Mozilla/5.0 (Linux; Android 7.1.1; SM-N950F Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36
Issue or Feature Request Description:
It happens after refreshing page and trying to fetch a file. This file was fetched before refreshing and it has networkFirst strategy

@mick-feller
Copy link

We have been noticing the same issue happening.

It's hardly impossible to reproduce but we got it on a handful of machines, what happened (or at least i think) we had some backend issue's and the service workers kicked in during this time. At that moment something is going south and i'm getting this exact same issue. I can confirm that on version 3.0.1 it was stopping the service worker all together and serving empty files. I've updated to version 3.2.0 and at least the service worker is now returning content.

All though it seems impossible to recover the service worker after this has happened unless you forcefully unregister the service worker and reinitialize it.

My caching strategy is mixed between staleWhileRevalidate, cacheFirst and preCache.

I wish i could put a case together were I could 100% replicate it but it's near impossible at this moment.

Do you have any pointers for me in how to recover the service worker after something like this happens?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase. workbox-strategies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants