angular / angular/angular

Service worker not updating after its response headers are updated

Open
#58,406 11 comments 0 reactions 0 assignees View on GitHub
area: service-worker open for contributions
Dominant language
TypeScript
Stars
101k
Forks
27.5k
Avg merge
1d 19h
Merged PRs (30d)
288

Description

### Which @angular/* package(s) are the source of the bug?

Don't known / other

### Is this a regression?

Yes

### Description

Hello,

I have came across a strange issue. I have a CSP policy setup done by the server through response headers. I also have a service worker running for the same page.

When I update the CSP in the server, its getting updated for the index.html, But the service-worker itself is not getting updated with the new CSP. The service worker is throwing CSP errors even tough the index.html and other assets got the CSP updated.

could you please give an way to re-load/update the service worker(ngsw-worker.js), when its own response headers are updated?

### Please provide a link to a minimal reproduction of the bug

_No response_

### Please provide the exception or error you saw

_No response_

### Please provide the environment you discovered this bug in (run `ng version`)

Angular CLI: 17.1.4
Node: 20.12.2
Package Manager: npm 10.8.2
OS: win32 x64

Angular: 17.1.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1701.2
@angular-devkit/build-angular 17.1.2
@angular-devkit/core 17.1.2
@angular-devkit/schematics 17.1.2
@angular/cli 17.1.4
@schematics/angular 17.1.2
ng-packagr 17.1.2
rxjs 7.8.0
typescript 5.3.3
zone.js 0.14.3

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Research direction

The report concerns ngsw-worker.js and CSP response headers; start by reproducing the behavior with Angular 17.1.2 and the stated service-worker setup. Inspect the Angular service-worker update path and verify how changed response headers are handled. Done means the service worker can receive updated CSP headers without requiring an unspecified manual reload.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.