Skip to content

bug(ServiceWorker): multiple apps with ServiceWorker on one domain #9260

@skydever

Description

@skydever

Versions

Angular CLI: 1.6.0
Node: 8.9.4
OS: linux x64
Angular: 5.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

@angular/cli: 1.6.0
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

Repro steps

see issue #21388 from the angular repository.

Observed behavior

multiple apps with service worker break when hosted on one origin/domain (different baseHref). the CacheDatabase keys are the same and one app will overwrite the entries from another app.

Desired behavior

The CacheDatabase should not be able to modify entries from another app when hosted on the same origin/domain.

Mention any other details that might be useful (optional)

I found this line of code, where the ngsw-worker.js will be read and afterwards written to the build folder. Just replacing ngsw:db with ngsw:db:${baseHref} for this kind of entries in workerCode would do the job (tried it out by manually modifying ngsw-worker.js after the build process). What is the best way to handle that (string replacement would fail fast I guess, or maybe not)? The service worker does not know what the baseHref will be, so I created this issue here too. Would like to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions