{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/24790","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/24790/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/24790/comments","events_url":"https://api.github.com/repos/angular/angular/issues/24790/events","html_url":"https://github.com/angular/angular/issues/24790","id":339131052,"node_id":"MDU6SXNzdWUzMzkxMzEwNTI=","number":24790,"title":"Issues with ServiceWorker in Angular 6","user":{"login":"hassanasad","id":7580112,"node_id":"MDQ6VXNlcjc1ODAxMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/7580112?v=4","gravatar_id":"","url":"https://api.github.com/users/hassanasad","html_url":"https://github.com/hassanasad","followers_url":"https://api.github.com/users/hassanasad/followers","following_url":"https://api.github.com/users/hassanasad/following{/other_user}","gists_url":"https://api.github.com/users/hassanasad/gists{/gist_id}","starred_url":"https://api.github.com/users/hassanasad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hassanasad/subscriptions","organizations_url":"https://api.github.com/users/hassanasad/orgs","repos_url":"https://api.github.com/users/hassanasad/repos","events_url":"https://api.github.com/users/hassanasad/events{/privacy}","received_events_url":"https://api.github.com/users/hassanasad/received_events","type":"User","site_admin":false},"labels":[{"id":708923209,"node_id":"MDU6TGFiZWw3MDg5MjMyMDk=","url":"https://api.github.com/repos/angular/angular/labels/comp:%20service-worker","name":"comp: service-worker","color":"c5def5","default":false},{"id":348933279,"node_id":"MDU6TGFiZWwzNDg5MzMyNzk=","url":"https://api.github.com/repos/angular/angular/labels/state:%20Need%20repro","name":"state: Need repro","color":"e11d21","default":false},{"id":130606843,"node_id":"MDU6TGFiZWwxMzA2MDY4NDM=","url":"https://api.github.com/repos/angular/angular/labels/type:%20bug/fix","name":"type: bug/fix","color":"EEEEEE","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/angular/angular/milestones/83","html_url":"https://github.com/angular/angular/milestone/83","labels_url":"https://api.github.com/repos/angular/angular/milestones/83/labels","id":3143880,"node_id":"MDk6TWlsZXN0b25lMzE0Mzg4MA==","number":83,"title":"needsTriage","description":"Milestone for all issues that haven't been triaged yet","creator":{"login":"ocombe","id":265378,"node_id":"MDQ6VXNlcjI2NTM3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/265378?v=4","gravatar_id":"","url":"https://api.github.com/users/ocombe","html_url":"https://github.com/ocombe","followers_url":"https://api.github.com/users/ocombe/followers","following_url":"https://api.github.com/users/ocombe/following{/other_user}","gists_url":"https://api.github.com/users/ocombe/gists{/gist_id}","starred_url":"https://api.github.com/users/ocombe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocombe/subscriptions","organizations_url":"https://api.github.com/users/ocombe/orgs","repos_url":"https://api.github.com/users/ocombe/repos","events_url":"https://api.github.com/users/ocombe/events{/privacy}","received_events_url":"https://api.github.com/users/ocombe/received_events","type":"User","site_admin":false},"open_issues":148,"closed_issues":474,"state":"open","created_at":"2018-02-26T14:22:18Z","updated_at":"2018-07-07T14:20:20Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2018-07-07T09:10:31Z","updated_at":"2018-07-07T15:35:04Z","closed_at":"2018-07-07T14:20:20Z","author_association":"NONE","body":"<!--\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<!-- Check one of the following options with \"x\" -->\r\n<pre><code>\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[X] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->\r\n[ ] Performance issue\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[ ] Other... Please describe:\r\n</code></pre>\r\n\r\n## Current behavior\r\n<!-- Describe how the issue manifests. -->\r\nWhen new build is pushed to S3 (along with service worker files [ngsw-worker.js and ngsw.json]) we run cache invalidation from CloudFront. The browser using ServiceWorker even picks up the new change and downloads the files. However it doesn't trigger the `swUpdate.available()` method and it downloads the same files on every request that goes out to check `ngsw.json` file even though there is no new change in them. We are checking for new version every 30 seconds.\r\n![screenshot 2018-07-07 13 50 50](https://user-images.githubusercontent.com/7580112/42409001-0a87b4ec-81ed-11e8-8de0-89cd8265ac8a.png)\r\n\r\n\r\n## Expected behavior\r\n<!-- Describe what the desired behavior would be. -->\r\nThe ServiceWorker should just fetch the file once and trigger `swUpdate.available()` method. If there is some issue - it should throw an exception or console message if there is some error.\r\n\r\n## Minimal reproduction of the problem with instructions\r\n<!--\r\nFor bug reports please provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://stackblitz.com or similar (you can use this template as a starting point: https://stackblitz.com/fork/angular-gitter).\r\n-->\r\nService Worker setup code in `app.component.ts`:\r\n```\r\n\tprivate setupServiceWorker(): void {\r\n\t\tif ( this.swUpdate.isEnabled && environment.allowServiceWorker ) {\r\n\t\t\t// Service worker is enabled\r\n\t\t\t// Check for update\r\n\t\t\tthis.appUpdateIntervalSub = interval( 1000 * 60 * 0.5 ).subscribe( () => {\r\n\t\t\t\tthis.swUpdate.checkForUpdate();\r\n\t\t\t} );\r\n\r\n\t\t\t// New app version is available\r\n\t\t\tthis.appUpdateAvailableSub = this.swUpdate.available.subscribe( () => {\r\n\t\t\t\tconsole.log('SW Available');\r\n\t\t\t\t// New version of app is available - notify user to refresh browser\r\n\t\t\t\tthis.showAppUpdateMessage = true;\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n```\r\n\r\n**P.S:** It works okay on local webserver:\r\n```\r\nng build --configuration=alpha && cd dist && http-server -p 8080\r\n```\r\nalpha config in **angular.json**:\r\n```\r\n            \"alpha\": {\r\n              \"optimization\": true,\r\n              \"outputHashing\": \"all\",\r\n              \"sourceMap\": true,\r\n              \"extractCss\": true,\r\n              \"namedChunks\": false,\r\n              \"aot\": true,\r\n              \"extractLicenses\": true,\r\n              \"vendorChunk\": false,\r\n              \"buildOptimizer\": false,\r\n              \"serviceWorker\": true,\r\n              \"fileReplacements\": [\r\n                {\r\n                  \"replace\": \"src/environments/environment.ts\",\r\n                  \"with\": \"src/environments/environment.alpha.ts\"\r\n                }\r\n              ]\r\n            },\r\n```\r\n\r\n## Environment\r\n\r\n<pre><code>\r\n```\r\nAngular CLI: 6.0.8\r\nNode: 10.1.0\r\nOS: darwin x64\r\nAngular: 6.0.7\r\n... common, compiler, compiler-cli, core, forms, http\r\n... language-service, platform-browser, platform-browser-dynamic\r\n... router, service-worker\r\n\r\nPackage                           Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect         0.6.8\r\n@angular-devkit/build-angular     0.6.8\r\n@angular-devkit/build-optimizer   0.6.8\r\n@angular-devkit/core              0.6.8\r\n@angular-devkit/schematics        0.6.8\r\n@angular/cli                      6.0.8\r\n@ngtools/webpack                  6.0.8\r\n@schematics/angular               0.6.8\r\n@schematics/update                0.6.8\r\nrxjs                              6.2.1\r\ntypescript                        2.7.2\r\nwebpack                           4.8.3\r\n```\r\n\r\n\r\nBrowser:\r\nChrome 67.0.3396.99\r\n \r\nFor Tooling issues:\r\n- Node version: v10.1.0\r\n- Platform:  Mac OS High Sierra 10.13.5\r\n\r\nOthers:\r\n<!-- Anything else relevant?  Operating system version, IDE, package manager, HTTP server, ... -->\r\n</code></pre>\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/403223683","html_url":"https://github.com/angular/angular/issues/24790#issuecomment-403223683","issue_url":"https://api.github.com/repos/angular/angular/issues/24790","id":403223683,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzIyMzY4Mw==","user":{"login":"gkalpak","id":8604205,"node_id":"MDQ6VXNlcjg2MDQyMDU=","avatar_url":"https://avatars2.githubusercontent.com/u/8604205?v=4","gravatar_id":"","url":"https://api.github.com/users/gkalpak","html_url":"https://github.com/gkalpak","followers_url":"https://api.github.com/users/gkalpak/followers","following_url":"https://api.github.com/users/gkalpak/following{/other_user}","gists_url":"https://api.github.com/users/gkalpak/gists{/gist_id}","starred_url":"https://api.github.com/users/gkalpak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkalpak/subscriptions","organizations_url":"https://api.github.com/users/gkalpak/orgs","repos_url":"https://api.github.com/users/gkalpak/repos","events_url":"https://api.github.com/users/gkalpak/events{/privacy}","received_events_url":"https://api.github.com/users/gkalpak/received_events","type":"User","site_admin":false},"created_at":"2018-07-07T15:35:04Z","updated_at":"2018-07-07T15:35:04Z","author_association":"MEMBER","body":"Nevermind. I write that before I saw you found the culprit.\r\n\r\n(In case you're curious, `/ngsw/state` is a route that the SW serves (even if it is not is your routes) and shows info about the SW's current state, which is useful for debugging. If you are getting 404, then the SW is probably not activated.)"}}
{"actor":{"display_login":"gkalpak"}}