Above is the Screenshot, the project is live @ https://portfolio.arturgvieira.com
I am running one initial HTTP REST request to an Express Server. I think the Service Worker does not like that. When the app fails to register the Worker, in the mobile device I'm testing the app on, the screen goes blank. Any information would be highly appreciated.
Thanks in advance!
Local Environment:
Linux / nvm installed NodeJS 9+ / React + Express + Firebase
When I visit the site it registered for me, haha [Chrome]. I'm not sure what's going on here / why Firefox doesn't like it.
Maybe @jeffposnick would have an idea.
Thanks for the response!
Ditto, the site registers the service worker successfully in both Chrome and Firefox when I visit it.
Requesting any resource within the service worker using http: (rather than https:) would lead to the error you saw. Did you recently change things to use https: instead?
In any case, can you try reproducing this in a Chrome Incognito window locally? If you can't reproduce it, then it's likely due to something you've since changed in your code.
Ooh, maybe a firefox extension is injecting a script into the page which contains a http call. Does this reproduce on a Firefox private/incognito window?
On a private/incognito window, the service worker does not fail to register.
I'm at a loss for what could have led to that specific failure that you're seeing, since we can't reproduce it ourselves and since there are protections in place in the c-r-a codebase to prevent you from, e.g., registering a service worker from a cross-origin URL, or registering a service worker via a http: URL when your main site is accessed via https:.
You talk about the REST request being an issue鈥攁re you seeing proper behavior when you locally test it without the REST call? And the failure only occurs when you have the call?
Also, I noticed that you have HTTP caching (of 1 hour) enabled for your service-worker.js file. Chrome respects that HTTP caching (Firefox does not), and that can make it frustrating to test changes to your site. I'd recommend disabling HTTP caching of service-worker.js in the meantime to eliminate one other source of inconsistency.
Thanks for the response, and the comments. I am currently reviewing whether to keep the current features usage of this and another website. Trying to balance feature usage and writing standards compliant websites. It's the current challenge and I think this is part of a bigger standards review I need to do.
@jeffposnick I was unable to reproduce in Chrome, I have changed the code, but in Firefox I am still unable to register the worker due to failure during registration.
The REST calls, which currently there are a few small content calls. Fail in Internet Explorer, around the same time the registration for the service worker fails in Firefox.
I wanted to ask you about the caching config, I don't remember setting it up for 1 hour, maybe it was set as the default?
I removed the REST calls and the service worker still does not register.
@arturgvieira I believe it's one of your extensions in Firefox; try disabling them one by one to find the culprit.
I removed all the extensions, still no luck. I did some more testing, I found a call to www.example.com/null by the service worker, returns a 404. Is that supposed to happen?
It's not supposed to happen (presumably), but at the same time, it's not necessarily a call that originates from the service worker. It might be another part of your web app that's inadvertently requesting that URL鈥攐nce the SW is installed, any web traffic that the SW responds to will be from "(from ServiceWorker)" even if it didn't originate from it.
Oh ok. Thank you.