Repository navigation
Disable serviceworkers on Safari browsers - #12907
Merged
Merged
Conversation
joshpuetz
requested review from
a team,
ludwiczakpawel and
msarit
and removed request for
a team
March 4, 2021 20:41
joshpuetz
requested review from
Zhao-Andy,
benhalpern,
jgaskins,
maestromac and
rhymes
and removed request for
ludwiczakpawel and
msarit
March 4, 2021 20:42
jgaskins
reviewed
Mar 4, 2021
jgaskins
left a comment
Contributor
There was a problem hiding this comment.
Do we know if not trying to load a SW at all will stop this or will it continue to use the existing installed SW?
mstruve
reviewed
Mar 4, 2021
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Contributor
Author
I'm not sure TBH, will defer to ServiceWorker experts like @benhalpern |
jgaskins
approved these changes
Mar 4, 2021
jgaskins
left a comment
Contributor
There was a problem hiding this comment.
We can always give it a shot. If it doesn't deregister the SW in Safari by not requesting it, maybe we can try again and run an empty SW in Safari.
1 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this? (check all applicable)
Description
This PR turns off serviceworkers on Safari browsers (both desktop and iOS). PR #12834 refactored serviceworkers significantly, removing almost all functionality from them except for the offline page support.
Something was lost in translation because that PR has resulted in GitHub, Twitter, and possibly other authentication methods no longer working. In particular the
fetcheventListener inapp/views/service_worker/index.js.erbis causing issues in Safari. Bypassing this check inapp/views/service_worker/index.js.erbis problematic: bothnavigator.userAgentas well asnavigator.vendorshould be checked, but Safari doesn't populatenavigator.vendorin service workers.Instead, I'm doing a check in
app/assets/javascripts/serviceworker-companion.jsfor Safari and skipping registration of the service worker if it's true (thanks for the idea @benhalpern). As a result of this PR, the offline page for Forem will no longer load in Safari.Related Tickets & Documents
#12834
possibly: #12899
QA Instructions, Screenshots, Recordings
To test locally, be sure to set
export SKIP_SERVICEWORKERS="false"in your.envfile.On Safari, you can verify serviceworkers aren't running by navigating to http://localhost:3000, and checking the menu Developer -> Service Workers. You should not see
localhostthere. You should be able to login via Github as normal. There shouldn't be an offline page:On Chrome, navigate to http://localhost:3000 and open Dev Tools. On the applications tab you should see a service worker for localhost. You should be able to login via Github as normal. The offline page should work as normal:
Added tests?
[Forem core team only] How will this change be communicated?
Will this PR introduce a change that impacts Forem members or creators, the
development process, or any of our internal teams? If so, please note how you
will share this change with the people who need to know about it.
Admin Guide, or
Storybook (for Crayons components)
or in a forem.dev post
[optional] What gif best describes this PR or how it makes you feel?