Skip to content

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. #2883

Description

@martynassimkevicius

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

const response = await 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions