Repository: GoogleChrome/workbox (language: javascript)

Issue:
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.
**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.


Discussion / hints:
Hello!

From reading your code, my guess is that you're seeing this with the second navigation route, the one using the `StaleWhileRevalidate` handler. Is that correct?

I believe that the you're seeing is logged by Chrome whenever `event.respondWith()` is called before the navigation preload promise settles, as this typically represents an error in your service worker's logic. In the case of using a `StaleWhileRevalidate` handler, it's not actually a logic error, though—the stale response is passed to `event.respondWith()` right away, and the preload response does end up being used afterwards to refresh the cache.

Adding a `waitUntil()` around that `fetch()` call in the `StrategyHandler` shouldn't be necessary, as the `StrategyHandler` has its own mechanism of coordinating all the promises that need to complete, and it orchestrates that via https://github.com/GoogleChrome/workbox/blob/1ec268901d6d8ac5286ec3b473d5b535e88260a3/packages/workbox-strategies/src/StrategyHandler.ts#L134

So basically, unless you're actually seeing unexpected behavior, I think the explanation for the logged message is that it's effectively a false positive, motivated by Chrome attempting to log something helpful. We can revisit this if that assessment seems incorrect.
I am getting canceled request for new cache and not updated cache on second navigation (best visible on refresh)
CC: @Snugug who might be running into something similar.

Fix patch:
diff --git a/packages/workbox-strategies/src/StaleWhileRevalidate.ts b/packages/workbox-strategies/src/StaleWhileRevalidate.ts
index 80ac1619a..1e8d37f8b 100644
--- a/packages/workbox-strategies/src/StaleWhileRevalidate.ts
+++ b/packages/workbox-strategies/src/StaleWhileRevalidate.ts
@@ -84,6 +84,7 @@ class StaleWhileRevalidate extends Strategy {
       // Swallow this error because a 'no-response' error will be thrown in
       // main handler return flow. This will be in the `waitUntil()` flow.
     });
+    void handler.waitUntil(fetchAndCachePromise);
 
     let response = await handler.cacheMatch(request);
 


Test patch: