Skip to content

Cancelling requests with service worker #48107

@oliveti

Description

@oliveti

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

service-worker

Is this a regression?

No

Description

When using a service worker and cancelling http requests (via unsubscribe for example), the underlying call made by service worker is not cancelled.

This could cause several issues like reaching maximum number of connections opened to a backend or useless backend load.

To reproduce the issue you can use the project I shared in github which is triggering calls to a slow backend and cancelling the calls except the last one (with and without service worker). You can see that, when using service worker, that last call have to wait for all the "cancelled" calls to be done before being fired.

I attach two screenshots of the demo code you can find in the repository.

Screenshot 2022-11-17 at 15 01 43

Screenshot 2022-11-17 at 15 02 16

Please provide a link to a minimal reproduction of the bug

https://github.com/oliveti/sw-cancellation-demo-2

Please provide the exception or error you saw

No response

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

Angular CLI: 14.2.9
Node: 16.14.0
Package Manager: npm 9.1.2 
OS: darwin arm64

Angular: 14.2.11
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.9
@angular-devkit/build-angular   14.2.9
@angular-devkit/core            14.2.9
@angular-devkit/schematics      14.2.9
@angular/cli                    14.2.9
@angular/pwa                    0.5.3
@schematics/angular             14.2.9
rxjs                            7.5.7
typescript                      4.7.4

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: service-workerIssues related to the @angular/service-worker package

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions