question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Service worker registration failed in Safari angular 8

See original GitHub issue

I updated my application from angular v7 to angular v8 and I have some problems with service workers with Safari. I have same error when enter in www.angular.io

[Error] Service worker registration failed with: TypeError: TypeError: Type error run (polyfills-es2015.75c15c263061f321fee9.js:1:1925) (anonymous function) (polyfills-es2015.75c15c263061f321fee9.js:1:12750) runTask (polyfills-es2015.75c15c263061f321fee9.js:1:2544) _ (polyfills-es2015.75c15c263061f321fee9.js:1:8987) promiseReactionJob

Safari Version 12.1.1 (14607.2.6.1.1) MacOs Mojave v10.14.5 Node v10.16.0

My package.json

{ “dependencies”: { “@angular/animations”: “^8.0.1”, “@angular/cdk”: “^8.0.1”, “@angular/common”: “^8.0.1”, “@angular/compiler”: “^8.0.1”, “@angular/core”: “^8.0.1”, “@angular/forms”: “^8.0.1”, “@angular/material”: “^8.0.1”, “@angular/platform-browser”: “^8.0.1”, “@angular/platform-browser-dynamic”: “^8.0.1”, “@angular/platform-server”: “^8.0.1”, “@angular/pwa”: “^0.800.3”, “@angular/router”: “^8.0.1”, “@angular/service-worker”: “^8.0.1”, “@nguniversal/express-engine”: “^8.0.0-rc.1”, “@nguniversal/module-map-ngfactory-loader”: “^8.0.0-rc.1”, “compression”: “^1.7.4”, “tslib”: “^1.10.0”, “rxjs”: “~6.4.0”, “zone.js”: “~0.9.1” }, “devDependencies”: { “@angular-devkit/build-angular”: “^0.800.3”, “@angular/cli”: “^8.0.3”, “@angular/compiler-cli”: “^8.0.1”, “@angular/language-service”: “^8.0.1”, “@types/express-useragent”: “^0.2.21”, “@types/jasmine”: “^3.3.13”, “@types/jasminewd2”: “^2.0.6”, “@types/node”: “^12.0.8”, “codelyzer”: “^5.1.0”, “express”: “^4.17.1”, “jasmine-core”: “~3.4.0”, “jasmine-spec-reporter”: “~4.2.1”, “karma”: “~4.1.0”, “karma-chrome-launcher”: “~2.2.0”, “karma-coverage-istanbul-reporter”: “~2.0.1”, “karma-jasmine”: “~2.0.1”, “karma-jasmine-html-reporter”: “^1.4.0”, “protractor”: “^5.4.2”, “ts-loader”: “^6.0.2”, “ts-node”: “^7.0.1”, “tslint”: “^5.17.0”, “typescript”: “~3.4.5”, “webpack-cli”: “^3.3.4” } }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
hassanasadcommented, Aug 6, 2019

@H--o-l Thanks for your thoughtful reply. Yes you are right. We have found the issue and resolved it and initially it felt like a regression but after doing intense debugging it appears to have been an error occurring due to some library updates on Server Side.

It was indeed a bug that was only showing up in Safari when the ServiceWorker was trying to send a POST request to server and being denied access. Everything was working fine on Chrome and Firefox. Safari was adding Pragma and Cache-control headers with the service worker request which were being denied on the server because they weren’t in the allowed headers list. I cannot seem to understand why we are unable to reproduce this error using Postman. Anyways - Yes, what appeared to have been a regression was NOT actually a regression (but it was indeed quite weird issue to debug)

1reaction
hassanasadcommented, Aug 6, 2019

@kara Service worker using Safari is not working in Angular 8.2.0 anymore. The POST requests are giving Gateway 504 errors.

UPDATE: This is the error i am getting

[Error] Fetch API cannot load MY_API_URL due to access control checks.
[Error] Failed to load resource: Request header field Cache-Control is not allowed by Access-Control-Allow-Headers.

2nd UPDATE: Turns out the error was coming in Safari due to some server side configuration. Its not a regression in Angular 8.2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Service Worker Registration Failed - Stack Overflow
Solved: First thing is service worker only works in secure mode either in https or localhost. It doesnot work in local resources like ......
Read more >
Angular Service Worker - Step-By-Step Guide
More than that, this module registers the Angular Service Worker in the browser (if Service Worker support is available), by loading the ngsw- ......
Read more >
Angular service worker introduction
For service workers to be registered, the application must be accessed over HTTPS, not HTTP. Browsers ignore service workers on pages that are...
Read more >
ServiceWorkerRegistration.active - Web APIs - MDN Web Docs
The active property of the ServiceWorkerRegistration interface returns a service worker whose ServiceWorker.state is activating or activated ...
Read more >
Service worker registration failed. Cannot read property ...
8. 9. 10. 11. 12. 13. 14. // eslint-disable-next-line no-undef. chrome.action.onClicked.addListener((tab) => {. console.log( "working" );.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found