nuxt-community / pwa-module

Zero config PWA solution for Nuxt.js
https://pwa.nuxtjs.org
MIT License
1.23k stars 171 forks source link

fix(workbox): add additional details for uncaught errors and fix chromium CORS #417

Closed pi0 closed 3 years ago

pi0 commented 3 years ago

When opening chromium devtools on first load, it makes a request that violates Request.cache spec: (chromium#823392)

The "only-if-cached" mode can only be used if the request's mode is "same-origin". Cached redirects will be followed if the request's redirect property is "follow" and the redirects do not violate the "same-origin" mode. (mdn)

Solution is to rewrite workbox request by detecting this condition and change cache option to default


Since there might be more causes for uncaught errors (https://github.com/nuxt-community/pwa-module/issues/176#issuecomment-665722983) this PR is also adding more context to production errors with full context:

Before: (production - debug disabled):

image

After: (production)

image

For more context, one may still enable production debugging in nuxt.config:

{
  pwa: {
     workbox: { debug: true }
  }
}

This PR resolves #176 with best efforts. IMPORTANT: Disabling clientsClaim as workaround with other defaults is NOT SAFE and may cause caching problems and if you was doing it before, should keep it with default value

codecov[bot] commented 3 years ago

Codecov Report

Merging #417 (dcb519f) into master (be2bc76) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #417   +/-   ##
=======================================
  Coverage   85.28%   85.28%           
=======================================
  Files           9        9           
  Lines         367      367           
  Branches      122      122           
=======================================
  Hits          313      313           
  Misses         54       54           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update be2bc76...dcb519f. Read the comment docs.