René's URL Explorer Experiment


Title: [Service Worker] Can't update sw if in SAFE_MODE · Issue #22087 · angular/angular · GitHub

Open Graph Title: [Service Worker] Can't update sw if in SAFE_MODE · Issue #22087 · angular/angular

X Title: [Service Worker] Can't update sw if in SAFE_MODE · Issue #22087 · angular/angular

Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request => Please do not submit support request here...

Open Graph Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request => P...

X Description: I'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request ...

Opengraph URL: https://github.com/angular/angular/issues/22087

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Service Worker] Can't update sw if in SAFE_MODE","articleBody":"\u003c!--\r\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\r\n\r\nISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.\r\n-->\r\n\r\n## I'm submitting a...\r\n\u003c!-- Check one of the following options with \"x\" -->\r\n\u003cpre>\u003ccode>\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[x] Bug report  \u003c!-- Please search GitHub for a similar issue or PR before submitting -->\r\n[ ] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n\u003c/code>\u003c/pre>\r\n\r\n## Current behavior\r\nWhen the service worker is installed / initialized the first time, it fetches the `ngsw.json`. If the content of `ngsw.json` is not an valid json the sw goes into SAFE_MODE:\r\n\r\nhttps://github.com/angular/angular/blob/c8a1a14b87e5907458e8e87021e47f9796cb3257/packages/service-worker/worker/src/driver.ts#L320-L325\r\n\r\nFrom thereon it is impossible to update the service worker. If you call `SwUpdate.checkForUpdate()` it never resolves or rejects and no new fetch to `ngsw.json` is performed due to the fact that messages are ignored in SAFE_MODE:\r\n\r\nhttps://github.com/angular/angular/blob/c8a1a14b87e5907458e8e87021e47f9796cb3257/packages/service-worker/worker/src/driver.ts#L189-L193\r\n\r\nReplacing the wrong `ngsw.json` with the correct one does only resolve this issue if:\r\n* the service worker is unregistered (if `ngsw.json` did not contain json. for example it contains html)\r\n* or the sw is unregistered and the cache is cleared (if `ngsw.json` did contain a json. ex: `{ \"test\": 123 }`).\r\nThis also triggers the following error: `Error: Invariant violated (initialize): latest hash null has no known manifest`\r\n\r\nThis issue occurred on our firebase hosted app. It seems a cache sometimes returns a html page with a 2xx status instead of the `ngsw.json` and broke our service worker. We also needed to clear the cache and unregister the service worker on some mobile clients. It might be that firebase sends sometimes a wrong json file or there might be another way to lock the service worker in the SAFE_MODE with `latest hash null` error. \r\n\r\n## Expected behavior\r\n* It should be possible to update the sw with `SwUpdate.checkForUpdate()` when the sw is in SAFE_MODE\r\n* Maybe the sw should try to refetch the `ngsw.json`? I'm not sure when and if this would be the appropriated way to handle this issue.\r\n\r\n## Minimal reproduction of the problem with instructions\r\nRepo: https://github.com/sean-nicholas/test-angular-service-worker\r\n\r\n* run `npm run build`\r\n* `cd` into `dist``\r\n* change the content of `ngsw.json` to \r\n  * For non json case: `asdjknkfdnjgdfkaslkdm` \r\n  * For json case: `{ \"test\": 123 }`\r\n* run `http-server` (or something similar) in `dist` folder\r\n* goto localhost in incognito mode\r\n* you get the error\r\n  * For non json case: `Unexpected token a in JSON at position 0`\r\n  * For json case: `TypeError: Cannot convert undefined or null to object`\r\n* sw installation fails and sw goes into SAFE_MODE\r\n* reload & press the `Check for SW Update` Button\r\n* `Checking` will stay true and not fall back to false after a few ms\r\n* Replace the content of `ngsw.json` with the correct data\r\n\r\nFor non json case:\r\n* Unregister the sw & reload -> it works again\r\n\r\nFor json case:\r\n* Unregister the sw & reload\r\n* Error: `Error: Invariant violated (initialize): latest hash null has no known manifest` occures\r\n* `Check for SW Update` seems to work but if you reload it fails (does not resolve) again\r\n* Clear the cache, unregister the sw & reload -> it works again\r\n\r\n## What is the motivation / use case for changing the behavior?\r\nThe service worker should not lock itself into a state were it can not be updated anymore.\r\n\r\n\r\n## Environment\r\n\r\n\u003cpre>\u003ccode>\r\n\"@angular/animations\": \"^5.2.4\",\r\n\"@angular/cdk\": \"^5.2.0\",\r\n\"@angular/common\": \"^5.2.4\",\r\n\"@angular/compiler\": \"^5.2.4\",\r\n\"@angular/core\": \"^5.2.4\",\r\n\"@angular/forms\": \"^5.2.4\",\r\n\"@angular/http\": \"^5.2.4\",\r\n\"@angular/material\": \"^5.2.0\",\r\n\"@angular/platform-browser\": \"^5.2.4\",\r\n\"@angular/platform-browser-dynamic\": \"^5.2.4\",\r\n\"@angular/router\": \"^5.2.4\",\r\n\"@angular/service-worker\": \"^5.2.4\"\r\n\r\nBrowser:\r\n(Only tested in)\r\n- [x] Chrome (desktop) version 64.0.3282.140\r\n- [x] Chrome (Android) version 64.0.3282.137\r\n- [ ] Chrome (iOS) version XX\r\n- [ ] Firefox version XX\r\n- [ ] Safari (desktop) version XX\r\n- [ ] Safari (iOS) version XX\r\n- [ ] IE version XX\r\n- [ ] Edge version XX\r\n \u003c/code>\u003c/pre>\r\n","author":{"url":"https://github.com/sean-nicholas","@type":"Person","name":"sean-nicholas"},"datePublished":"2018-02-08T09:57:55Z","url":"https://github.com/angular/angular/issues/22087"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ae18075f-e978-d2fe-66d1-4fe76f9d0c3d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9380:33444D:1301DEA:194C49E:6B01258F
html-safe-nonce4638db4b6554e63390d2e0cbeef6940c028cb1cd4ea023ff9f574ed10f0ea467
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzgwOjMzNDQ0RDoxMzAxREVBOjE5NEM0OUU6NkIwMTI1OEYiLCJ2aXNpdG9yX2lkIjoiMzA4NzA5MTM2MDIxODU1NTc5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac85dbda9ddee41cb527847ec2ee43849dbbdf27b52b5daf52133e66a30b7362a9
hovercard-subject-tagissue:295449064
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/22087/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a476c8a5831d3fea6cf1e32fa229388d165d1f62b7be07f0c5cb93fce8a9b601/angular/angular/issues/22087
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a476c8a5831d3fea6cf1e32fa229388d165d1f62b7be07f0c5cb93fce8a9b601/angular/angular/issues/22087
og:image:altI'm submitting a... [ ] Regression (a behavior that used to work and stopped working in a new release) [x] Bug report [ ] Feature request [ ] Documentation issue or request [ ] Support request => P...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesean-nicholas
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/22087#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F22087
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F22087
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/22087
Reloadhttps://github.com/angular/angular/issues/22087
Reloadhttps://github.com/angular/angular/issues/22087
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests141 (141)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/22087
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/22087
[Service Worker] Can't update sw if in SAFE_MODEhttps://github.com/angular/angular/issues/22087#top
area: service-workerIssues related to the @angular/service-worker packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20service-worker%22
freq2: mediumhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq2%3A%20medium%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/sean-nicholas
sean-nicholashttps://github.com/sean-nicholas
on Feb 8, 2018https://github.com/angular/angular/issues/22087#issue-295449064
angular/packages/service-worker/worker/src/driver.tshttps://github.com/angular/angular/blob/c8a1a14b87e5907458e8e87021e47f9796cb3257/packages/service-worker/worker/src/driver.ts#L320-L325
c8a1a14https://github.com/angular/angular/commit/c8a1a14b87e5907458e8e87021e47f9796cb3257
angular/packages/service-worker/worker/src/driver.tshttps://github.com/angular/angular/blob/c8a1a14b87e5907458e8e87021e47f9796cb3257/packages/service-worker/worker/src/driver.ts#L189-L193
c8a1a14https://github.com/angular/angular/commit/c8a1a14b87e5907458e8e87021e47f9796cb3257
https://github.com/sean-nicholas/test-angular-service-workerhttps://github.com/sean-nicholas/test-angular-service-worker
mheveryhttps://github.com/mhevery
area: service-workerIssues related to the @angular/service-worker packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20service-worker%22
on Feb 13, 2018https://github.com/angular/angular/issues/22087#event-1470677678
alxhubhttps://github.com/alxhub
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
freq2: mediumhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq2%3A%20medium%22
severity3: brokenhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22severity3%3A%20broken%22
on Feb 15, 2018https://github.com/angular/angular/issues/22087#event-1476983105
https://github.com/alxhub
alxhubhttps://github.com/alxhub
on Feb 15, 2018https://github.com/angular/angular/issues/22087#issuecomment-366094565
https://github.com/sean-nicholas
sean-nicholashttps://github.com/sean-nicholas
on Feb 15, 2018https://github.com/angular/angular/issues/22087#issuecomment-366099563
https://github.com/petivagyok16
petivagyok16https://github.com/petivagyok16
on Feb 19, 2018https://github.com/angular/angular/issues/22087#issuecomment-366676796
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on Feb 26, 2018https://github.com/angular/angular/issues/22087#event-1492225608
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Mar 20, 2018https://github.com/angular/angular/issues/22087#issuecomment-374608094
#22883https://github.com/angular/angular/pull/22883
@petivagyok16https://github.com/petivagyok16
@sean-nicholashttps://github.com/sean-nicholas
@alxhubhttps://github.com/alxhub
#31109 (comment)https://github.com/angular/angular/issues/31109#issuecomment-509275663
https://github.com/k-schneider
k-schneiderhttps://github.com/k-schneider
on Apr 17, 2018https://github.com/angular/angular/issues/22087#issuecomment-381796310
https://github.com/freefred81
freefred81https://github.com/freefred81
on Apr 19, 2019https://github.com/angular/angular/issues/22087#issuecomment-484806089
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Jul 26, 2019https://github.com/angular/angular/issues/22087#issuecomment-515592990
#31109https://github.com/angular/angular/issues/31109
#31865https://github.com/angular/angular/pull/31865
/ngsw/statehttps://angular.io/guide/service-worker-devops#locating-and-analyzing-debugging-information
gkalpakhttps://github.com/gkalpak
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 26, 2019https://github.com/angular/angular/issues/22087#event-2513661310
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 15, 2019https://github.com/angular/angular/issues/22087#issuecomment-531547417
automatic conversation locking policyhttps://github.com/angular/angular/blob/67d80f/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 15, 2019https://github.com/angular/angular/issues/22087#event-2634543040
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/22087
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/22087
area: service-workerIssues related to the @angular/service-worker packagehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20service-worker%22
freq2: mediumhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq2%3A%20medium%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.