DockYard/ember-service-worker-index

Fallback strategy does not return from cache upon network error / when offline

Opened this issue · 0 comments

Version

0.7.1

Steps to reproduce

  1. Check out https://github.com/ember-cli/ember-new-output (I'm using version 3.12)
  2. ember install ember-service-worker (9.0.1) && ember install ember-service-worker-index (0.7.1)
  3. Enable fallback strategy in ember-cli-build.js:
  let app = new EmberApp(defaults, {
    'esw-index': {
      strategy: 'fallback',
    },
  });
  1. ember serve
  2. Open http://localhost:4200/ in Chrome (89.0.4389.82)
  3. Use DevTools to confirm service worker is registered and esw-index-1 cache contains /index.html entry.
  4. Use DevTools Network tab to set the network to "Offline"
  5. Refresh the page.
  6. Observe that page fails to load:

Screen Shot 2021-03-17 at 3 53 48 PM

Expected Behavior

The cached index.html document should be used by the browser when the network is offline.

Note that this repro would also need ember-service-worker-asset-cache or similar for the app to fully load, so the expected behavior is simply that the document would load and you would instead see failed network requests for assets.

Actual Behavior

The service worker propagates the network error to the browser, even though the file exists in the cache.