question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Service Workers - Consolidated issues list

See original GitHub issue

This is a consolidation of issues and fixes service workers in CRA.

For general discussion of service workers see issue #2398


Last updated: 18/06/2017 00:10:00 GMT

  • SWI1: Service workers are causing CRA to show up when someone hosts a non CRA app on the same address:host.

PR #2551 attempt to address this by auto reloading non-service worker apps.

  • SWI2 User sees old app when revisiting a site, they must refresh to see the updated site.

PR #2426 attempts to address by showing a toast notifying user to refresh.

  • SWI3 service-worker.js can be cached accidently or by default on some hosts, meaning that new versions of apps do not appear until the cache period ends.

Eventually browsers should force no-cache on service workers, but this is only implemented in firefox currently. In the mean time, only fix is to ensure no-cache is set on service-worker.js SW Spec Issue, Firefox ✔, Chrome

PR #2563 is a proof of concept how this could be addressed in CRA.

  • SWI4 Browser support is currently patchy. Different browsers support different specs and there is no polyfills to align browsers, things means developers need to be aware of browser differences

There is currently no fix for this.

  • SWI5 Odd behaviour for the end users when an app is cached but no data is loaded, images don’t load etc

There is currently no fix for this. Developers must know of this behaviour an plan for it. Due to the fact users aren’t allowed to fully configure the service worker, they won’t ever be able to cache API data and images (I think? @jeffposnick).

A developer can store data in localStorage and load that initially / if offline.

  • SWI6 When registerServiceWorker.js is updated to fix issues, it will not be updated for current users of CRA. Breaking the ‘as long as you don’t eject you always have the latest features’

Currently no PR but we could move the logic out of registerServiceWorker.js and add it to react-scripts config folder.


Please feel free to add any issues that you have encounter using CRA with service workers enabled.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:34 (22 by maintainers)

github_iconTop GitHub Comments

12reactions
gaearoncommented, Jan 19, 2018

We’re moving forward with making service-workers opt in in the next major release. They’re still readily available behind a single line change but won’t be registered by default.

https://github.com/facebookincubator/create-react-app/pull/3817

I hope this is a satisfactory conclusion for most users. We can revisit this in a year or two.

3reactions
petetntcommented, Jan 9, 2018

👍

Bikeshedding, but as a developer something like

// index.js

// change this to true if you want to register a service worker (see https://[CRA docs])
registerServiceWorker(false);

// registerServiceWorker.js

export default function register(registerServiceWorker) {
  if ('serviceWorker' in navigator) {
    if (registerServiceWorker === false) {
      unregister();
      return;
    }

    if (process.env.NODE_ENV === 'production' ) {
       ...
    }
  }
}

Sounds like a neat way to solve the problem without breaking existing behaviour but giving an easy way to nuke the serviceWorker for those that upgrade with minimal code changes. I can send a PR for this if wanted 🐈

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consolidated Sanctions List (Non-SDN Lists)
In order to make it easier to comply with OFAC's sanctions regulations, the office is now offering all of its non-SDN sanctions lists...
Read more >
Public Service Loan Forgiveness (PSLF) Program Overhaul
There, you'll see a list of each loan you have borrowed, even if you have paid the loan off or consolidated it into...
Read more >
Columbus Consolidated Government
The Official Web Site of the Columbus, Georgia Consolidated Government (CCG). Quality People, Providing Quality Service. 100 10th Street, Columbus, ...
Read more >
Residential Blog - Consolidated Communications
The hybrid workplace is here to stay, and for employees, this means relying on ... with new threats and challenges emerging each day....
Read more >
Lafayette Consolidated Government Contact Us
Do not use the online tool to report emergencies, instead, call 911. Lafayette Utilities System. To Report Issues: Street Light Problems: (337) 291-5700;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found