remix-pwa: `PrecacheHandler` Bug

Seems like this function is wrong:

function getPathname(route: EntryRoute) {
      if (route.index) return '/';

      let pathname = '';
      if (route.path && route.path.length > 0) {
        pathname = '/' + route.path;
      }
      if (route.parentId) {
        const parentPath = getPathname(manifest.routes[route.parentId]);
        if (parentPath) {
          pathname = parentPath + pathname;
        }
      }
      return pathname;
    }

I am getting many errors similar to this:

entry.workbox.js:1963 remix-pwa Failed to cache data for /?_data=routes%2Fdashboard._index: TypeError: Failed to execute 'add' on 'Cache': Request failed

and it seems like you are checking if a route has .index and then defaulting to /. Many routes can end in ._index and they have nothing to do with the / route.

Also it was hard to know where all these errors were coming from without a bunch of commenting out, trial and error. Is it possible to put more logging that explains that this is the precaching section that is within the self.addEventListener("message", (event: ExtendableMessageEvent) callback

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (12 by maintainers)

Most upvoted comments

@jmaldon1 Fixed and added a new feature, docs update rolling out somewhile later. In the meantime, the new changes goes as thus:

const precacheHandler = new PrecacheHandler(
 assetCacheName: string,
 dataCacheName: string,
 documentCacheName: string,
 state: {
  ignoredRoutes?: RegExp[] | string[] | ((route: EntryRoute) => boolean)[] | ((route: EntryRoute) => boolean) | null;
  }
 }
)

Ah yeah so i have a return redirect('/dashboard/x'); in the loader of dashboard._index.tsx. That could be why

I am getting many errors similar to this: entry.workbox.js:1963 remix-pwa Failed to cache data for /?_data=routes%2Fdashboard._index: TypeError: Failed to execute 'add' on 'Cache': Request failed

By chance, do these routes throw errors in their loaders? or return an response of code 500?

They don’t throw errors, the issue is that the route is /dashboard?_data=routes%2Fdashboard._index not /?_data=routes%2Fdashboard._index

Yeah sure, It may take a while but hopefully I will get it to it.

@dev-afzalansari Is this something you could maybe explore a bit when you are less busy? Pretty please.