The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle.
See original GitHub issueBackground
I am trying to use a navigationPreload and a cache data by StaleWhileRevalidate
strategy for a navigation request.
Problem I am getting an error message:
The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle.
and cache is not updated
Finding
I think for this case this.waitUntil
is missing to wait for a response
const response = await this.waitUntil(this.fetch(input));
Question I am doing something wrong in my code or this finding is a needed fix?
navigationPreload.enable();
self.addEventListener('install', () => {
self.skipWaiting();
});
clientsClaim();
const routes = [
new RegExp(`/route1`),
new RegExp(`/route2`)
];
registerRoute(new NavigationRoute(new NetworkOnly(), {
denylist: routes,
}));
registerRoute(new NavigationRoute(new StaleWhileRevalidate({
cacheName: NAVIGATION_CACHE_NAME,
}), {
allowlist: routes,
}));
Thank you so much for creating this great library.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
The service worker navigation preload request was cancelled ...
If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle. service-worker.js: workbox.
Read more >React.js error: The service worker navigation preload request ...
If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle. I see this error on the...
Read more >Getting The service worker navigation preload request was ...
If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle. I'm getting the error: The service...
Read more >Worker navigation preload request was cancelled before ...
The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or ...
Read more >The service worker navigation preload request - Google Support
If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle." Also, "Unchecked runtime.lastError: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, sorry for initially assuming that this was just logging noise. I was able to reproduce failures to update the cache during the revalidate step of
StaleWhileRevalidate
, when that strategy is being used for navigation requests, and navigation preload is enabled.The fix is adding in a
waitUntil()
around the entire promise that performs the revalidation. It should make it into the next release of Workbox.This fix is now in the https://github.com/GoogleChrome/workbox/releases/tag/v6.5.0 release.