Title: Fetch current service worker version/hash · Issue #45414 · angular/angular · GitHub
Open Graph Title: Fetch current service worker version/hash · Issue #45414 · angular/angular
X Title: Fetch current service worker version/hash · Issue #45414 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description As you know debugging service worker in production can be a pain. Something that has made it easier for me is to display the hash version...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description As you know debugging service worker in production can be a pain. Something that has made it easi...
X Description: Which @angular/* package(s) are relevant/related to the feature request? service-worker Description As you know debugging service worker in production can be a pain. Something that has made it easi...
Opengraph URL: https://github.com/angular/angular/issues/45414
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fetch current service worker version/hash","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\r\n\r\nservice-worker\r\n\r\n### Description\r\n\r\nAs you know debugging service worker in production can be a pain. Something that has made it easier for me is to display the hash version in the settings menu of my applications, it provides a way to view \"version numbers\" of deployed service workers and then I can prepare a **safety-worker.js** for the correct version.\r\n\r\nSo when I get a user who reports to me they are having issues, I ask them to go to settings and send me the version number there. Before I started using this method it was a pain to explain to users that they must clear cache or unregister.\r\n\r\nLast I checked, the hash is only really emitted when update events are fired (and it is not type safe).\r\n\r\nI would like an easier/official way of accessing the service workers hash/version to make it easier to debug and identify what version of deployed service worker is giving issues in deployed apps.\r\n\r\n### Proposed solution\r\n\r\nA new method to get/expose the hash/version\r\n\r\ne.g. this.swUpdate.getHash() or this.swUpdate.getCurrentVersion();\r\n\r\nit would also be nice to perhaps have this.swUpdate.getPreviousHash();\r\n\r\n### Alternatives considered\r\n\r\nContinue using a workaround for this value, perhaps add workaround to documentation.\r\n\r\nHere is code I have written\r\n\r\n```ts\r\n availableUpdate$: Observable\u003cvoid> = this.swUpdate.available.pipe(\r\n map((event: UpdateAvailableEvent) => {\r\n const updateInfo = {\r\n current_version: event.current.hash,\r\n update_version: event.available.hash,\r\n };\r\n\r\n // this.storage.set('pwaVersion', updateInfo.current_version).subscribe();\r\n\r\n this.swUpdate.activateUpdate();\r\n })\r\n );\r\n```\r\n\r\n```ts\r\n activatedUpdate$: Observable\u003cvoid> = this.swUpdate.activated.pipe(\r\n map((event: UpdateActivatedEvent) => {\r\n const previousUpdate =\r\n event.previous?.hash !== undefined ? event.previous.hash : 'none';\r\n\r\n const successfulUpdateInfo = {\r\n previous_version: previousUpdate,\r\n current_version: event.current.hash,\r\n };\r\n\r\n // this.storage.set('pwaVersion', successfulUpdateInfo.current_version).subscribe();\r\n })\r\n );\r\n```","author":{"url":"https://github.com/tayambamwanza","@type":"Person","name":"tayambamwanza"},"datePublished":"2022-03-22T22:21:02Z","url":"https://github.com/angular/angular/issues/45414"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:950aca2c-75ca-fdd2-500a-40b48ff28f18 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E904:EA06E:136964D:18D5534:6B010F73 |
| html-safe-nonce | 23ca0c3f3ac3634591a4d7d33ace4c2134b0321a5427853ef06acbbeb1a15ae2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTA0OkVBMDZFOjEzNjk2NEQ6MThENTUzNDo2QjAxMEY3MyIsInZpc2l0b3JfaWQiOiIzOTcxMzk4MjM1Njc0NzA5ODc1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ecef818e693a5569ca608c44d3e45a2a464d08ee6ef95997f828fe49e8119055 |
| hovercard-subject-tag | issue:1177366398 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/45414/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8e8a7f14d088f007a6aae8452ed64eedb89427c9a6e6c8efddb52a3d25133170/angular/angular/issues/45414 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8e8a7f14d088f007a6aae8452ed64eedb89427c9a6e6c8efddb52a3d25133170/angular/angular/issues/45414 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? service-worker Description As you know debugging service worker in production can be a pain. Something that has made it easi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tayambamwanza |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width