preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Service worker doesn't take over when going offline and navigating to different route

Open gtsop opened this issue 5 years ago • 1 comments

Do you want to request a feature or report a bug? feature, maybe bug?

What is the current behaviour? Going offline and visiting a different route for the first time fails to render the app contents.

If the current behaviour is a bug, please provide the steps to reproduce.

  • Using the default app created by preact-cli
  • Using Chrome 80.0.3987.163
  • I serve the app using npm run serve
  • I visit localhost:5000
  • I see the the contents of the home page
  • I open up the chrome dev tools > Network and check the "offline" toggle
  • I click the "Me" navigation item
  • There is no content in the app. Console throws:
Error: Loading CSS chunk 3 failed.
(/route-profile.chunk.62c75.css)
    at HTMLLinkElement.o.<computed>.o.<computed>.<computed>.t.push.o.<computed>.f.onerror (bundle.974af.esm.js:1)

 Error: Loading CSS chunk 3 failed.
(/route-profile.chunk.62c75.css)
    at HTMLLinkElement.o.<computed>.o.<computed>.<computed>.t.push.o.<computed>.f.onerror (bundle.974af.esm.js:1)

The app tried to fetch the assets from the network and failed.

What is the expected behaviour? The service worker should take over.

If this is a feature request, what is motivation or use case for changing the behaviour? There is a buisness need to be able to download the whole app on the first page load, being able to go offline and use the rest of the app (and routes) as normal.

Please mention other relevant information.

Please paste the results of preact info here.

Environment Info:

  System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.7 - ~/.nvm/versions/node/v12.14.1/bin/npm
  Browsers:
    Chrome: 80.0.3987.163
    Safari: 13.1
  npmPackages:
    preact: ^10.3.2 => 10.3.4
    preact-cli: ^3.0.0-rc.6 => 3.0.0-rc.10
    preact-render-to-string: ^5.1.4 => 5.1.4
    preact-router: ^3.2.1 => 3.2.1
  npmGlobalPackages:
    preact-cli: 3.0.0-rc.9

EDIT I initially reported the service worker would work if I refreshed the page. Turns out that behaviour was there because the "Update on reload" checkbox was checked in the chrome's dev tools > Application tab.

gtsop avatar Apr 04 '20 12:04 gtsop

by any chance is the "Bypass for network" option enabled?

prateekbh avatar Apr 20 '20 17:04 prateekbh