question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Background 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));

https://github.com/GoogleChrome/workbox/blob/0b5d9d816ab828d32021d05a808c63d17a28dbf1/packages/workbox-strategies/src/StrategyHandler.ts#L240

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:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
jeffposnickcommented, Jan 13, 2022

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.

2reactions
jeffposnickcommented, Feb 23, 2022
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found